//============================================================================================
/**
 * @file	wo_main.c
 * @brief	技教え/思い出し処理　メイン
 * @author	Hiroyuki Nakamura
 * @date	06.05.09
 */
//============================================================================================
#include "common.h"
#include "system/procsys.h"
#include "system/fontproc.h"
#include "system/msgdata.h"
#include "system/wordset.h"
#include "system/numfont.h"
#include "system/arc_util.h"
#include "system/clact_tool.h"
#include "system/wipe.h"
#include "system/window.h"
#include "system/pmfprint.h"
#include "system/bmp_list.h"
#include "system/bmp_menu.h"
#include "system/touch_subwindow.h"
#include "system/softsprite.h"
#include "system/cursor_move.h"

#include "savedata/config.h"
#include "battle/battle_common.h"
#include "battle/wazatype_icon.h"
#include "poketool/waza_tool.h"
#include "contest/contest.h"
#include "contest/con_tool.h"
#include "msgdata/msg.naix"
#include "msgdata/msg_waza_oboe.h"
#include "application/app_tool.h"
#include "application/p_status.h"

#include "application/waza_oshie.h"
#include "wo_bmp_def.h"
#include "wo_snd_def.h"
#include "waza_oshie_gra.naix"


//============================================================================================
//	定数定義
//============================================================================================

#define MFRM_POKE	(GF_BGL_FRAME0_M)
#define MFRM_PARAM	(GF_BGL_FRAME2_M)
#define MFRM_BACK	(GF_BGL_FRAME3_M)

#define SFRM_MSG	(GF_BGL_FRAME0_S)
#define SFRM_PARAM	(GF_BGL_FRAME2_S)
#define SFRM_BACK	(GF_BGL_FRAME3_S)

#define MFRM_POKE_PRI	(1)
#define MFRM_PARAM_PRI	(2)
#define MFRM_BACK_PRI	(3)
#define SFRM_MSG_PRI	(0)
#define SFRM_PARAM_PRI	(2)
#define SFRM_BACK_PRI	(3)

enum {
	WIN_STR_CLASS = 0,		// 「ぶんるい」
	WIN_STR_ATTACK,			// 「いりょく」
	WIN_STR_HIT,			// 「めいちゅう」
	WIN_PRM_ATTACK,			// 威力値
	WIN_PRM_HIT,			// 命中値
	WIN_BTL_INFO,			// 戦闘説明
	WIN_MSG,				// メッセージウィンドウ
	WIN_EXP,				// 説明ウィンドウ
	WIN_ABTN,				// 決定ボタンウィンドウ
	WIN_BACK,				// 戻るボタンウィンドウ
	WIN_LIST,				// 技リスト
	WIN_YESNO,				// はい/いいえ

	WIN_TITLE,				// タイトル
	WIN_MWAZA,				// 上　技リスト
	WIN_MPRM,				// 上　パラメータ

	WIN_MAX
};

enum {
	WO_CLA_ARROW_D = 0,			// リストカーソル下
	WO_CLA_ARROW_U,			// リストカーソル上
	WO_CLA_CURSOR,			// 選択カーソル
	WO_CLA_KIND,			// 分類アイコン
	WO_CLA_TYPE1,			// タイプアイコン１
	WO_CLA_TYPE2,			// タイプアイコン２
	WO_CLA_TYPE3,			// タイプアイコン３
	WO_CLA_TYPE4,			// タイプアイコン４

	WO_CLA_TYPE5,			// タイプアイコン１
	WO_CLA_TYPE6,			// タイプアイコン２
	WO_CLA_TYPE7,			// タイプアイコン３
	WO_CLA_TYPE8,			// タイプアイコン４
	WO_CLA_MAX
};

typedef struct _WO_3DWORK{
	GF_CAMERA_PTR	camera;
	void*			ssm;

	SOFT_SPRITE_ARC	ssa;	///<ソフトウェアスプライト
	SOFT_SPRITE	* ss;
}WO_3DWORK;

// ボタンアニメ
typedef struct {
	u8	px;
	u8	py;
	u8	sx;
	u8	sy;
	u16	cnt;
	u16	seq;
	int	next;
}BUTTON_ANM_WORK;

typedef struct {
	WAZAOSHIE_DATA * dat;			// 外部設定データ

	GF_BGL_INI * bgl;				// BGLデータ

	GF_BGL_BMPWIN	win[WIN_MAX];	// BMPウィンドウデータ

	MSGDATA_MANAGER * mman;		// メッセージデータマネージャ
	WORDSET * wset;				// 単語セット
	STRBUF * mbuf;				// 汎用文字列展開領域
	STRBUF * pp1_str;			// PP用文字列展開領域(PP/MPP)
	STRBUF * pp2_str;			// PP用文字列展開領域(PP/MPP)

	BMPLIST_WORK * lw;			// BMPリストワーク
	BMP_MENULIST_DATA * ld;		// BMPリストデータ

	BMPMENU_WORK * mw;			// BMPメニューワーク
	TOUCH_SW_SYS*	ynbtn_wk;	// YesNoボタンワーク

	// セルアクター
	CATS_SYS_PTR	csp;
	CATS_RES_PTR	crp;
	CATS_ACT_PTR	cap[WO_CLA_MAX];

	WO_3DWORK		p3d;

	PSTATUS_DATA	psd;
	PROC * subProc;

	int	next_seq;				// 次のシーケンス
	int key_mode;

	u8	sel_max;

	u8	midx;					// メッセージインデックス
	u8	ynidx;					// はい・いいえID

	u8	cpos_x;				// カーソルポジション
	u8	cpos_y;				// カーソルポジション
	u8	cur_pos;				// カーソルポジション

	void*	pSBufDParts;
	NNSG2dScreenData*	pSDParts;

	CURSOR_MOVE_WORK * cmwk;	// カーソル移動ワーク
	u16	cm_pos;					// カーソル移動の現在の位置
	u16	enter_flg;				//「おぼえる」表示フラグ

	BUTTON_ANM_WORK	button_anm_work;

}WO_WORK;


typedef int (*WO_SEQ_FUNC)(WO_WORK*);

// はい・いいえ処理
typedef struct {
	WO_SEQ_FUNC	yes;	// はい
	WO_SEQ_FUNC	no;		// いいえ
}YESNO_FUNC;

// ページ
enum {
	WO_PAGE_BATTLE = 0,	// 戦闘
	WO_PAGE_CONTEST		// コンテスト
};

// メインシーケンス
enum {
	SEQ_FADE_WAIT = 0,	// フェード終了待ち
	SEQ_SELECT,			// 技セレクト
	SEQ_MSG_WAIT,		// メッセージ終了待ち
	SEQ_YESNO_PUT,		// はい・いいえセット
	SEQ_YESNO_WAIT,		// はい・いいえ選択待ち
	SEQ_WAZA_SET,		// 技覚え
	SEQ_WAZADEL_SET,	// 忘れて技覚え
	SEQ_DEL_CHECK,		// 忘れさせる技をチェック
	SEQ_FADEOUT_SET,	// フェードアウトセット
	SEQ_END,			// 終了

	SEQ_PST_INIT,		// ステータス画面へ
	SEQ_PST_CALL,		// ステータス画面呼び出し
	SEQ_PST_WAIT,		// ステータス画面終了待ち

	SEQ_BUTTON_ANM,		// ボタンアニメ
	SEQ_RET_BUTTON,		//「もどる」
	SEQ_ENTER_BUTTON,	//「おぼえる」
};

//============================================================================================
//	プロトタイプ宣言
//============================================================================================
static void WO_DispInit( WO_WORK * wk );
static void WO_DispExit( WO_WORK * wk );

static void WO_VBlank( void * work );
static void WO_VramBankSet(void);
static void WO_BgSet( GF_BGL_INI * ini );
static void WO_BgExit( GF_BGL_INI * ini );
static void WO_BgGraphicSet( WO_WORK * wk, ARCHANDLE* p_handle );
static void WO_BgGraphicRelease( WO_WORK * wk );
static void WO_BmpWinSet( WO_WORK * wk );
static void WO_BmpWinExit( WO_WORK * wk );
static void WO_MsgCreate( WO_WORK * wk );
static void WO_MsgRelease( WO_WORK * wk );
static int WO_SeqFadeWait( WO_WORK * wk );

static int WO_SeqSelectDecide(WO_WORK* wk);
static void WO_InputModeChange( WO_WORK * wk );
//static int WO_SeqSelectKeyIn( WO_WORK * wk );
//static int WO_SeqSelectTouchIn( WO_WORK * wk );
static int WO_SeqSelectInputCheck( WO_WORK * wk );

static int WO_SeqSelect( WO_WORK * wk );
static int WO_SeqFadeOutSet( WO_WORK * wk );
static int WO_SeqMsgWait( WO_WORK * wk );
static int WO_SeqYesNoPut( WO_WORK * wk );
static int WO_SeqYesNoWait( WO_WORK * wk );
static int WO_SeqWazaSet( WO_WORK * wk );
static int WO_SeqWazaDelSet( WO_WORK * wk );
static int WO_SeqDelCheck( WO_WORK * wk );
static int WO_SeqPstInit( WO_WORK * wk );
static int WO_SeqPstCall( WO_WORK * wk );
static int WO_SeqPstWait( WO_WORK * wk );

static void StrPut( WO_WORK * wk, u32 widx, u32 fnt, u32 col, u32 mode ,u8 py);
static void WO_PageChange( WO_WORK * wk );
static void WO_DefStrWrite( WO_WORK * wk );
static void WO_WazaListDraw( WO_WORK * wk );
static void WO_WazaListMake( WO_WORK * wk );
static void WO_WazaListExit( WO_WORK * wk );
static void WO_AButtonDraw( WO_WORK * wk );

static void BattleWazaParamPut( WO_WORK * wk, u32 prm );

static void WO_MsgMake( WO_WORK * wk, u32 id );
static void WO_TalkMsgSet( WO_WORK * wk, u32 id );
static void WO_TalkMsgOff( WO_WORK * wk);
static BOOL WO_TalkMsgCallBack( MSG_PRINT_HEADER * mph, u16 value );
static u16 WO_SelWazaGet( WO_WORK * wk );
static u16 WO_DelWazaGet( WO_WORK * wk );
static u8 WO_WazaSetCheck( WO_WORK * wk );

static int WO_SetCheck_Yes( WO_WORK * wk );
static int WO_SetCheck_No( WO_WORK * wk );
static int WO_EndCheck_Yes( WO_WORK * wk );
static int WO_EndCheck_No( WO_WORK * wk );
static int WO_ChgCheck_Yes( WO_WORK * wk );
static int WO_ChgCheck_No( WO_WORK * wk );
static int WO_DelCheck_Yes( WO_WORK * wk );
static int WO_DelCheck_No( WO_WORK * wk );
static int WO_DelEnter_Yes( WO_WORK * wk );
static int WO_DelEnter_No( WO_WORK * wk );

static void WO_ObjInit( WO_WORK * wk, ARCHANDLE* p_handle );
static void WO_ObjFree( WO_WORK * wk );
//static void WO_ObjAnm( WO_WORK * wk );
static void WO_3DInit( WO_WORK * wk );
static void WO_3DMain(WO_3DWORK* wk);
static void WO_3DRelease( WO_3DWORK * wk );
static void WO_TypeIconChange( WO_WORK * wk, u16 waza, u16 num );
static void WO_TypeIconInit( WO_WORK * wk );
static void WO_TypeIconScroll( WO_WORK * wk, u16 old_scr, u16 new_scr );
static void WO_KindIconChange( WO_WORK * wk, u16 waza );
static void WO_SelCursorChange( WO_WORK * wk, u8 pos, u8 pal );
static void WO_ScrollCursorPut( WO_WORK * wk ,u8 idx,BOOL anm_f);
//static void WO_ScrollCursorOff( WO_WORK * wk );

static void WO_SubBGPartsDraw( WO_WORK * wk ,u8 px,u8 py,u8 sx, u8 sy,u8 ox,u8 oy);

static void CursorMoveInit( WO_WORK * wk );
static void CursorMoveExit( WO_WORK * wk );

static void ScrollButtonOnOff( WO_WORK * wk );
static void EnterButtonOnOff( WO_WORK * wk, BOOL flg );

static int RetButtonAnmInit( WO_WORK * wk, int next );
static int EnterButtonAnmInit( WO_WORK * wk, int next );
static int ButtonAnmMaun( WO_WORK * wk );
static int WO_SeqRetButton( WO_WORK * wk );
static int WO_SeqEnterButton( WO_WORK * wk );
static void WazaSelBgChange( WO_WORK * wk, u32 pos );
static int WazaSelectEnter( WO_WORK * wk );
static void PassiveSet( BOOL flg );


//============================================================================================
//	グローバル変数
//============================================================================================
// BMPウィンドウデータ
static const BMPWIN_DAT BmpWinData[] =
{
	{	// 「ぶんるい」
		SFRM_PARAM, WIN_STR_CLASS_PX, WIN_STR_CLASS_PY,
		WIN_STR_CLASS_SX, WIN_STR_CLASS_SY, WIN_STR_CLASS_PAL, WIN_STR_CLASS_CGX
	},
	{	// 「いりょく」
		SFRM_PARAM, WIN_STR_ATTACK_PX, WIN_STR_ATTACK_PY,
		WIN_STR_ATTACK_SX, WIN_STR_ATTACK_SY, WIN_STR_ATTACK_PAL, WIN_STR_ATTACK_CGX
	},
	{	// 「めいちゅう」
		SFRM_PARAM, WIN_STR_HIT_PX, WIN_STR_HIT_PY,
		WIN_STR_HIT_SX, WIN_STR_HIT_SY, WIN_STR_HIT_PAL, WIN_STR_HIT_CGX
	},
	{	// 威力値
		SFRM_PARAM, WIN_PRM_ATTACK_PX, WIN_PRM_ATTACK_PY,
		WIN_PRM_ATTACK_SX, WIN_PRM_ATTACK_SY, WIN_PRM_ATTACK_PAL, WIN_PRM_ATTACK_CGX
	},
	{	// 命中値
		SFRM_PARAM, WIN_PRM_HIT_PX, WIN_PRM_HIT_PY,
		WIN_PRM_HIT_SX, WIN_PRM_HIT_SY, WIN_PRM_HIT_PAL, WIN_PRM_HIT_CGX
	},
	{	// 戦闘説明
		SFRM_PARAM, WIN_BTL_INFO_PX, WIN_BTL_INFO_PY,
		WIN_BTL_INFO_SX, WIN_BTL_INFO_SY, WIN_BTL_INFO_PAL, WIN_BTL_INFO_CGX
	},
	{	// メッセージウィンドウ
		SFRM_MSG, WIN_MSG_PX, WIN_MSG_PY,
		WIN_MSG_SX, WIN_MSG_SY, WIN_MSG_PAL, WIN_MSG_CGX,
	},
	{	// 操作説明ウィンドウ
		SFRM_PARAM, WIN_EXP_PX, WIN_EXP_PY,
		WIN_EXP_SX, WIN_EXP_SY, WIN_EXP_PAL, WIN_EXP_CGX,
	},
	{	// Aボタン
		SFRM_PARAM, WIN_ABTN_PX, WIN_ABTN_PY,
		WIN_ABTN_SX, WIN_ABTN_SY, WIN_ABTN_PAL, WIN_ABTN_CGX
	},
	{	// 戻るボタンウィンドウ
		SFRM_PARAM, WIN_BACK_PX, WIN_BACK_PY,
		WIN_BACK_SX, WIN_BACK_SY, WIN_BACK_PAL, WIN_BACK_CGX,
	},
	{	// 技リスト
		SFRM_PARAM, WIN_LIST_PX, WIN_LIST_PY,
		WIN_LIST_SX, WIN_LIST_SY, WIN_LIST_PAL, WIN_LIST_CGX
	},
	{	// はい/いいえ
		SFRM_MSG, WIN_YESNO_PX, WIN_YESNO_PY,
		WIN_YESNO_SX, WIN_YESNO_SY, WIN_YESNO_PAL, WIN_YESNO_CGX
	},

	{	// タイトル
		MFRM_PARAM, WIN_TITLE_PX, WIN_TITLE_PY,
		WIN_TITLE_SX, WIN_TITLE_SY, WIN_TITLE_PAL, WIN_TITLE_CGX
	},
	{	// 技リスト
		MFRM_PARAM, WIN_MWAZA_PX, WIN_MWAZA_PY,
		WIN_MWAZA_SX, WIN_MWAZA_SY, WIN_MWAZA_PAL, WIN_MWAZA_CGX
	},
	{	// パラメータ
		MFRM_PARAM, WIN_MPRM_PX, WIN_MPRM_PY,
		WIN_MPRM_SX, WIN_MPRM_SY, WIN_MPRM_PAL, WIN_MPRM_CGX
	},
};

// メッセージテーブル
static const u32 MsgDataTbl[2][11] =
{
	{	// 技教え
		msg_waza_oboe_01,	// @0に　どのわざを　おぼえさせる？
		msg_waza_oboe_02,	// @1　を  おぼえさせますか？
		msg_waza_oboe_03,	// @0に　わざを  おぼえさせるのを　あきらめますか？
		msg_waza_oboe_04,	// @0は　あたらしく　@1を　おぼえた！▼"
		msg_waza_oboe_05,	// @0は　あたらしく　@1を　おぼえたい……▼　しかし　〜
		msg_waza_oboe_06,	// １　２の……　ポカン！▼　@0は　@1の つかいかたを　〜
		msg_waza_oboe_07,	// @0は　あたらしく @1を　おぼえた！▼
		msg_waza_oboe_08,	// それでは……　@1を　おぼえるのを　あきらめますか？"
		msg_waza_oboe_09,	// @0は　@1を　おぼえずに　おわった！▼
		msg_waza_oboe_10,	// @2は　おれいに　ハートのウロコを　１まい　あげた！▼
		msg_waza_oboe_11,	// @0を　わすれさせて　よろしいですね？"
	},
	{	// 技思い出し
		msg_waza_omoi_01,	// @0に どのわざを　おもいださせる？
		msg_waza_omoi_02,	// @1　を おもいだしますか？
		msg_waza_omoi_03,	// @0に　わざを おもいださせるのを　あきらめますか？
		msg_waza_omoi_04,	// @0は　わすれていた　@1を　おもいだした！▼
		msg_waza_omoi_05,	// @0は　@1を　おもいだしたい……▼　しかし　〜
		msg_waza_omoi_06,	// １　２の……　ポカン！▼　@0は　@1の つかいかたを　〜
		msg_waza_omoi_07,	// @0は　わすれていた　@1を　おもいだした！▼
		msg_waza_omoi_08,	// それでは……　@1を　おもいだすのを　あきらめますか？
		msg_waza_omoi_09,	// @0は　@1を　おもいださずに　おわった！▼
		msg_waza_omoi_10,	// @2は　おれいに ハートのウロコを　１まい　あげた！▼
		msg_waza_omoi_11,	// @0を　わすれさせて　よろしいですね？"
	}
};

// はい・いいえ処理テーブル
static const YESNO_FUNC YesNoFunc[] =
{
	{ WO_SetCheck_Yes, WO_SetCheck_No },	// @1　を  おぼえさせますか？
	{ WO_EndCheck_Yes, WO_EndCheck_No },	// @0に　わざを  おぼえさせるのを　あきらめますか？
	{ WO_ChgCheck_Yes, WO_ChgCheck_No },	// @0は　あたらしく　@1を　おぼえたい……▼　しかし　〜
	{ WO_DelCheck_Yes, WO_DelCheck_No },	// それでは……　@1を　おぼえるのを　あきらめますか？
	{ WO_DelEnter_Yes, WO_DelEnter_No },	// @0を　わすれさせて　よろしいですね？"
};

// セルアクターデータ
static const TCATS_OBJECT_ADD_PARAM_S ClactParamTbl[] =
{
	{	// リストカーソル下
		LIST_CUR_D_PX, LIST_CUR_D_PY, 0,
		ANMDW_ARROW_DT, 1, 2, NNS_G2D_VRAM_TYPE_2DSUB,
		{ WO_CHR_ID_ARROW_UD, WO_PAL_ID_OBJ, WO_CEL_ID_ARROW_UD, WO_ANM_ID_ARROW_UD, 0, 0 },
		2, 0
	},
	{	// リストカーソル上
		LIST_CUR_U_PX, LIST_CUR_U_PY, 0,
		ANMDW_ARROW_UT, 1, 2, NNS_G2D_VRAM_TYPE_2DSUB,
		{ WO_CHR_ID_ARROW_UD, WO_PAL_ID_OBJ, WO_CEL_ID_ARROW_UD, WO_ANM_ID_ARROW_UD, 0, 0 },
		2, 0
	},
	{	// 選択カーソル
		SEL_CURSOR_PX, SEL_CURSOR_PY, 0,
		ANMDW_CURSOR, 0, 3, NNS_G2D_VRAM_TYPE_2DSUB,
		{ WO_CHR_ID_ARROW_UD, WO_PAL_ID_OBJ, WO_CEL_ID_ARROW_UD, WO_ANM_ID_ARROW_UD, 0, 0 },
		2, 0
	},
	{	// 分類アイコン
		KIND_ICON_PX, KIND_ICON_PY, 0,
		0, 0, TICON_ACTPAL_IDX, NNS_G2D_VRAM_TYPE_2DSUB,
		{ WO_CHR_ID_KIND, WO_PAL_ID_OBJ, WO_CEL_ID_TYPE, WO_ANM_ID_TYPE, 0, 0 },
		2, 0
	},
	{	// タイプアイコン１
		TYPE_ICON1_PX, TYPE_ICON1_PY, 0,
		0, 1, TICON_ACTPAL_IDX, NNS_G2D_VRAM_TYPE_2DSUB,
		{ WO_CHR_ID_TYPE1, WO_PAL_ID_TYPE, WO_CEL_ID_TYPE, WO_ANM_ID_TYPE, 0, 0 },
		2, 0
	},
	{	// タイプアイコン２
		TYPE_ICON2_PX, TYPE_ICON2_PY, 0,
		0, 1, TICON_ACTPAL_IDX, NNS_G2D_VRAM_TYPE_2DSUB,
		{ WO_CHR_ID_TYPE2, WO_PAL_ID_TYPE, WO_CEL_ID_TYPE, WO_ANM_ID_TYPE, 0, 0 },
		2, 0
	},
	{	// タイプアイコン３
		TYPE_ICON3_PX, TYPE_ICON3_PY, 0,
		0, 1, TICON_ACTPAL_IDX, NNS_G2D_VRAM_TYPE_2DSUB,
		{ WO_CHR_ID_TYPE3, WO_PAL_ID_TYPE, WO_CEL_ID_TYPE, WO_ANM_ID_TYPE, 0, 0 },
		2, 0
	},
	{	// タイプアイコン４
		TYPE_ICON4_PX, TYPE_ICON4_PY, 0,
		0, 1, TICON_ACTPAL_IDX, NNS_G2D_VRAM_TYPE_2DSUB,
		{ WO_CHR_ID_TYPE4, WO_PAL_ID_TYPE, WO_CEL_ID_TYPE, WO_ANM_ID_TYPE, 0, 0 },
		2, 0
	},

	{	// タイプアイコン５
		TYPE_ICON5_PX, TYPE_ICON5_PY, 0,
		0, 1, TICON_ACTPAL_IDX_M, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ WO_CHR_ID_TYPE5, WO_PAL_ID_TYPE_M, WO_CEL_ID_TYPE, WO_ANM_ID_TYPE, 0, 0 },
		2, 0
	},
	{	// タイプアイコン６
		TYPE_ICON6_PX, TYPE_ICON6_PY, 0,
		0, 1, TICON_ACTPAL_IDX_M, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ WO_CHR_ID_TYPE6, WO_PAL_ID_TYPE_M, WO_CEL_ID_TYPE, WO_ANM_ID_TYPE, 0, 0 },
		2, 0
	},
	{	// タイプアイコン７
		TYPE_ICON7_PX, TYPE_ICON7_PY, 0,
		0, 1, TICON_ACTPAL_IDX_M, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ WO_CHR_ID_TYPE7, WO_PAL_ID_TYPE_M, WO_CEL_ID_TYPE, WO_ANM_ID_TYPE, 0, 0 },
		2, 0
	},
	{	// タイプアイコン８
		TYPE_ICON8_PX, TYPE_ICON8_PY, 0,
		0, 1, TICON_ACTPAL_IDX_M, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ WO_CHR_ID_TYPE8, WO_PAL_ID_TYPE_M, WO_CEL_ID_TYPE, WO_ANM_ID_TYPE, 0, 0 },
		2, 0
	},
};


//============================================================================================
//	プロセス関数
//============================================================================================

//--------------------------------------------------------------------------------------------
/**
 * プロセス関数：初期化
 *
 * @param	proc	プロセスデータ
 * @param	seq		シーケンス
 *
 * @return	処理状況
 */
//--------------------------------------------------------------------------------------------
PROC_RESULT WazaOshieProc_Init( PROC * proc, int * seq )
{
	WO_WORK * wk;

	sys_CreateHeap( HEAPID_BASE_APP, HEAPID_WAZAOSHIE, 0x24000 );

	wk = PROC_AllocWork( proc, sizeof(WO_WORK), HEAPID_WAZAOSHIE );
	memset( wk, 0, sizeof(WO_WORK) );
	wk->dat = PROC_GetParentWork( proc );

	WO_DispInit( wk );

	WO_SelCursorChange( wk, wk->dat->pos, PALDW_CURSOR );
	wk->next_seq = SEQ_SELECT;


	WO_ScrollCursorPut( wk ,0, FALSE);

	sys_VBlankFuncChange( WO_VBlank, wk );	// VBlankセット

	return PROC_RES_FINISH;
}

//--------------------------------------------------------------------------------------------
/**
 * プロセス関数：メイン
 *
 * @param	proc	プロセスデータ
 * @param	seq		シーケンス
 *
 * @return	処理状況
 */
//--------------------------------------------------------------------------------------------
PROC_RESULT WazaOshieProc_Main( PROC * proc, int * seq )
{
	WO_WORK * wk  = PROC_GetWork( proc );

	switch( *seq ){
	case SEQ_FADE_WAIT:		// フェード終了待ち
		*seq = WO_SeqFadeWait( wk );
		break;

	case SEQ_SELECT:		// 技セレクト
		*seq = WO_SeqSelect( wk );
		break;

	case SEQ_MSG_WAIT:		// メッセージ終了待ち
		*seq = WO_SeqMsgWait( wk );
		break;

	case SEQ_YESNO_PUT:		// はい・いいえセット
		*seq = WO_SeqYesNoPut( wk );
		break;

	case SEQ_YESNO_WAIT:	// はい・いいえ選択待ち
		*seq = WO_SeqYesNoWait( wk );
		break;

	case SEQ_WAZA_SET:		// 技覚え
		*seq = WO_SeqWazaSet( wk );
		break;

	case SEQ_WAZADEL_SET:	// 忘れて技覚え
		*seq = WO_SeqWazaDelSet( wk );
		break;

	case SEQ_DEL_CHECK:		// 忘れさせる技をチェック
		*seq = WO_SeqDelCheck( wk );
		break;

	case SEQ_FADEOUT_SET:	// フェードアウトセット
		*seq = WO_SeqFadeOutSet( wk );
		break;

	case SEQ_END:			// 終了
		return PROC_RES_FINISH;

	case SEQ_PST_INIT:		// ステータス画面へ
		*seq = WO_SeqPstInit( wk );
		break;

	case SEQ_PST_CALL:		// ステータス画面呼び出し
		*seq = WO_SeqPstCall( wk );
		return PROC_RES_CONTINUE;

	case SEQ_PST_WAIT:		// ステータス画面終了待ち
		*seq = WO_SeqPstWait( wk );
		return PROC_RES_CONTINUE;

	case SEQ_BUTTON_ANM:
		*seq = ButtonAnmMaun( wk );
		break;

	case SEQ_RET_BUTTON:
		*seq = WO_SeqRetButton( wk );
		break;

	case SEQ_ENTER_BUTTON:
		*seq = WO_SeqEnterButton( wk );
		break;
	}

	WO_3DMain(&wk->p3d);
//	WO_ObjAnm( wk );
	CATS_Draw( wk->crp );

	return PROC_RES_CONTINUE;
}

//--------------------------------------------------------------------------------------------
/**
 * プロセス関数：終了
 *
 * @param	proc	プロセスデータ
 * @param	seq		シーケンス
 *
 * @return	処理状況
 */
//--------------------------------------------------------------------------------------------
PROC_RESULT WazaOshieProc_End( PROC * proc, int * seq )
{
	WO_WORK * wk  = PROC_GetWork( proc );

	WO_DispExit( wk );

	PROC_FreeWork( proc );					// ワーク開放

	sys_DeleteHeap( HEAPID_WAZAOSHIE );

	return PROC_RES_FINISH;
}

//--------------------------------------------------------------------------------------------
/**
 * 初期設定
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_DispInit( WO_WORK * wk )
{
	ARCHANDLE* p_handle;

	sys_VBlankFuncChange( NULL, NULL );	// VBlankセット
	sys_HBlankIntrStop();				// HBlank停止

	GF_Disp_GX_VisibleControlInit();
	GF_Disp_GXS_VisibleControlInit();
	GX_SetVisiblePlane( 0 );
	GXS_SetVisiblePlane( 0 );

	MsgPrintTouchPanelFlagSet( MSG_TP_ON );

	//現在のキー動作モードを取得
	wk->key_mode = KeyTouchStatus_CheckTouchOrKey(wk->dat->kt_status);

	wk->bgl = GF_BGL_BglIniAlloc( HEAPID_WAZAOSHIE );

	p_handle = ArchiveDataHandleOpen( ARC_WAZAOSHIE_GRA, HEAPID_WAZAOSHIE );

	WO_VramBankSet();				// VRAM設定
	WO_BgSet( wk->bgl );			// BG設定
	WO_BgGraphicSet( wk, p_handle );			// BGグラフィックセット

	WO_ObjInit( wk, p_handle );
	WO_3DInit( wk );

	WO_MsgCreate( wk );
	WO_BmpWinSet( wk );
	WO_WazaListMake( wk );
	WO_PageChange( wk );

	WO_DefStrWrite( wk );

//	WO_InputModeChange(wk);

	CursorMoveInit( wk );

	APP_WipeStart( APP_WIPE_IN, HEAPID_WAZAOSHIE );

	sys_VBlankFuncChange( WO_VBlank, wk );	// VBlankセット

	ArchiveDataHandleClose( p_handle );
}

//--------------------------------------------------------------------------------------------
/**
 * 解放処理
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_DispExit( WO_WORK * wk )
{
	CursorMoveExit( wk );

	WO_WazaListExit( wk );
	WO_BmpWinExit( wk );
	WO_BgGraphicRelease( wk );
	WO_BgExit( wk->bgl );		// BGL削除

	WO_MsgRelease( wk );

	WO_3DRelease(&wk->p3d);
	WO_ObjFree( wk );

	//現在のキー動作モードを書き戻し
	KeyTouchStatus_SetTouchOrKey(wk->dat->kt_status,wk->key_mode);

	MsgPrintTouchPanelFlagSet( MSG_TP_OFF );

	DellVramTransferManager();

	sys_VBlankFuncChange( NULL, NULL );		// VBlankセット
}


//--------------------------------------------------------------------------------------------
/**
 * VBlank関数
 *
 * @param	work	ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_VBlank( void * work )
{
	WO_WORK * wk = work;

	GF_BGL_VBlankFunc( wk->bgl );
	SoftSpriteTextureTrans( wk->p3d.ssm );

	// セルアクター
	DoVramTransferManager();	// Vram転送マネージャー実行
	CATS_RenderOamTrans();

	OS_SetIrqCheckFlag( OS_IE_V_BLANK );
}

//--------------------------------------------------------------------------------------------
/**
 * VRAM設定
 *
 * @param	none
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_VramBankSet(void)
{
	GF_BGL_DISPVRAM tbl = {
		GX_VRAM_BG_128_B,				// メイン2DエンジンのBG
		GX_VRAM_BGEXTPLTT_NONE,			// メイン2DエンジンのBG拡張パレット

		GX_VRAM_SUB_BG_128_C,			// サブ2DエンジンのBG
		GX_VRAM_SUB_BGEXTPLTT_NONE,		// サブ2DエンジンのBG拡張パレット

		GX_VRAM_OBJ_16_G,				// メイン2DエンジンのOBJ
		GX_VRAM_OBJEXTPLTT_NONE,		// メイン2DエンジンのOBJ拡張パレット

		GX_VRAM_SUB_OBJ_16_I,			// サブ2DエンジンのOBJ
		GX_VRAM_SUB_OBJEXTPLTT_NONE,	// サブ2DエンジンのOBJ拡張パレット

		GX_VRAM_TEX_0_A,				// テクスチャイメージスロット
		GX_VRAM_TEXPLTT_0_F			// テクスチャパレットスロット
	};
	GF_Disp_SetBank( &tbl );
}

//--------------------------------------------------------------------------------------------
/**
 * BG設定
 *
 * @param	ini		BGLデータ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_BgSet( GF_BGL_INI * ini )
{
	{	// BG SYSTEM
		GF_BGL_SYS_HEADER BGsys_data = {
			GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BGMODE_0, GX_BG0_AS_3D,
		};
		GF_BGL_InitBG( &BGsys_data );
	}

	{	// PARAM FONT (BMP)
		GF_BGL_BGCNT_HEADER TextBgCntDat = {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01,
			MFRM_PARAM_PRI, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( ini, MFRM_PARAM, &TextBgCntDat, GF_BGL_MODE_TEXT );
		GF_BGL_ScrClear( ini, MFRM_PARAM );
	}
	{	// PLATE (CHAR)
		GF_BGL_BGCNT_HEADER TextBgCntDat = {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xf000, GX_BG_CHARBASE_0x04000, GX_BG_EXTPLTT_01,
			MFRM_BACK_PRI, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( ini, MFRM_BACK, &TextBgCntDat, GF_BGL_MODE_TEXT );
		GF_BGL_ScrClear( ini, MFRM_BACK );
	}

	{	// WINDOW (BMP)
		GF_BGL_BGCNT_HEADER TextBgCntDat = {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01,
			SFRM_MSG_PRI, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( ini, SFRM_MSG, &TextBgCntDat, GF_BGL_MODE_TEXT );
		GF_BGL_ScrClear( ini, SFRM_MSG );
	}

	{	// PARAM FONT (BMP)
		GF_BGL_BGCNT_HEADER TextBgCntDat = {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xf000, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01,
			SFRM_PARAM_PRI, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( ini, SFRM_PARAM, &TextBgCntDat, GF_BGL_MODE_TEXT );
		GF_BGL_ScrClear( ini, SFRM_PARAM );
	}

	{	// PLATE (CHAR)
		GF_BGL_BGCNT_HEADER TextBgCntDat = {
			0, 0, 0x1000, 0, GF_BGL_SCRSIZ_512x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xe000, GX_BG_CHARBASE_0x10000, GX_BG_EXTPLTT_01,
			SFRM_BACK_PRI, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( ini, SFRM_BACK, &TextBgCntDat, GF_BGL_MODE_TEXT );
		GF_BGL_ScrClear( ini, SFRM_BACK );
	}

	GF_BGL_ClearCharSet( MFRM_PARAM, 32, 0, HEAPID_WAZAOSHIE );
	GF_BGL_ClearCharSet( SFRM_MSG, 32, 0, HEAPID_WAZAOSHIE );

	//上画面をサブ,下画面をメインに変更
//	GX_SetDispSelect(GX_DISP_SELECT_SUB_MAIN);
}

//--------------------------------------------------------------------------------------------
/**
 * BG解放
 *
 * @param	ini		BGLデータ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_BgExit( GF_BGL_INI * ini )
{
	GF_Disp_GXS_VisibleControl(
		GX_PLANEMASK_BG0 | GX_PLANEMASK_BG2 |
		GX_PLANEMASK_BG3 | GX_PLANEMASK_OBJ, VISIBLE_OFF );

	GF_BGL_BGControlExit( ini, SFRM_BACK );
	GF_BGL_BGControlExit( ini, SFRM_PARAM );
	GF_BGL_BGControlExit( ini, SFRM_MSG );
	GF_BGL_BGControlExit( ini, MFRM_BACK );
	GF_BGL_BGControlExit( ini, MFRM_PARAM );

	sys_FreeMemory( HEAPID_WAZAOSHIE, ini );

	//上画面をメイン,下画面をサブに戻す
	GX_SetDispSelect(GX_DISP_SELECT_MAIN_SUB);
}

//--------------------------------------------------------------------------------------------
/**
 * グラフィックデータセット
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_BgGraphicSet( WO_WORK * wk, ARCHANDLE* p_handle )
{
	APP_ArcFileVramLoad(wk->bgl,HEAPID_WAZAOSHIE,
		p_handle,ARC_WAZAOSHIE_GRA,NARC_waza_oshie_gra_bgd_NCGR,
		MFRM_BACK,AFVL_MODE_CHAR,0,0);
	APP_ArcFileVramLoad(wk->bgl,HEAPID_WAZAOSHIE,
		p_handle,ARC_WAZAOSHIE_GRA,NARC_waza_oshie_gra_bgu_back_NSCR,
		MFRM_BACK,AFVL_MODE_SCRN,0x800,0);
	APP_ArcFileVramLoad(wk->bgl,HEAPID_WAZAOSHIE,
		p_handle,ARC_WAZAOSHIE_GRA,NARC_waza_oshie_gra_bgd_NCLR,
		MFRM_BACK,AFVL_MODE_PLTT,0,0);

	APP_ArcFileVramLoad(wk->bgl,HEAPID_WAZAOSHIE,
		p_handle,ARC_WAZAOSHIE_GRA,NARC_waza_oshie_gra_bgd_NCGR,
		SFRM_BACK,AFVL_MODE_CHAR,0,0);
	APP_ArcFileVramLoad(wk->bgl,HEAPID_WAZAOSHIE,
		p_handle,ARC_WAZAOSHIE_GRA,NARC_waza_oshie_gra_bgd_back_NSCR,
		SFRM_BACK,AFVL_MODE_SCRN,0x800,0);
	APP_ArcFileVramLoad(wk->bgl,HEAPID_WAZAOSHIE,
		p_handle,ARC_WAZAOSHIE_GRA,NARC_waza_oshie_gra_bgd_NCLR,
		SFRM_BACK,AFVL_MODE_PLTT,0,0);

	//スクリーンリソース取得
	wk->pSBufDParts = ArcUtil_HDL_ScrnDataGet(
						p_handle,
						NARC_waza_oshie_gra_bgd_parts_NSCR,
						FALSE,
						&wk->pSDParts,
						HEAPID_WAZAOSHIE );

	TalkFontPaletteLoad( PALTYPE_SUB_BG, WO_PAL_TALK_FONT * 32, HEAPID_WAZAOSHIE );
	SystemFontPaletteLoad( PALTYPE_MAIN_BG, WO_PAL_SYS_FONT*32, HEAPID_WAZAOSHIE);
	SystemFontPaletteLoad( PALTYPE_SUB_BG, WO_PAL_SYS_FONT*32, HEAPID_WAZAOSHIE);

	// 会話ウィンドウセット
	TalkWinGraphicSet(
		wk->bgl, SFRM_MSG, WO_TALK_WIN_CGX,
		WO_PAL_TALK_WIN, CONFIG_GetWindowType(wk->dat->cfg), HEAPID_WAZAOSHIE );
}

static void WO_BgGraphicRelease( WO_WORK * wk )
{
	sys_FreeMemoryEz(wk->pSBufDParts);
}

//--------------------------------------------------------------------------------------------
/**
 * BMPウィンドウセット
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_BmpWinSet( WO_WORK * wk )
{
	u32	i;

	FontProc_LoadFont( FONT_TOUCH, HEAPID_WAZAOSHIE );

	for( i=0; i<WIN_MAX; i++ ){
		GF_BGL_BmpWinAddEx( wk->bgl, &wk->win[i], &BmpWinData[i] );
		GF_BGL_BmpWinDataFill( &wk->win[i], 0 );
	}

	GF_BGL_BmpWinOffVReq( &wk->win[WIN_ABTN] );

	//YesNoボタンシステムワーク確保
	wk->ynbtn_wk = TOUCH_SW_AllocWork(HEAPID_WAZAOSHIE);
}

//--------------------------------------------------------------------------------------------
/**
 * BMPウィンドウ削除
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_BmpWinExit( WO_WORK * wk )
{
	u32	i;

	//YesNoボタンシステムワーク解放
	TOUCH_SW_FreeWork( wk->ynbtn_wk);

	for( i=0; i<WIN_MAX; i++ ){
		GF_BGL_BmpWinDel( &wk->win[i] );
	}
//	MsgPrintAutoFlagSet( MSG_TP_RECT_OFF );

	FontProc_UnloadFont( FONT_TOUCH );
}

//--------------------------------------------------------------------------------------------
/**
 * メッセージ関連作成
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_MsgCreate( WO_WORK * wk )
{
	wk->mman = MSGMAN_Create(
					MSGMAN_TYPE_NORMAL, ARC_MSG, NARC_msg_waza_oboe_dat, HEAPID_WAZAOSHIE );
	wk->wset = WORDSET_Create( HEAPID_WAZAOSHIE );

	wk->mbuf = STRBUF_Create( TMP_MSGBUF_SIZ, HEAPID_WAZAOSHIE );
	wk->pp1_str = MSGMAN_AllocString( wk->mman, msg_waza_oboe_01_04);
	wk->pp2_str = MSGMAN_AllocString( wk->mman, msg_waza_oboe_01_10);
}

//--------------------------------------------------------------------------------------------
/**
 * メッセージ関連削除
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_MsgRelease( WO_WORK * wk )
{
	MSGMAN_Delete( wk->mman );
	WORDSET_Delete( wk->wset );
	STRBUF_Delete( wk->mbuf );
	STRBUF_Delete( wk->pp1_str );
	STRBUF_Delete( wk->pp2_str );
}



//--------------------------------------------------------------------------------------------
/**
 * シーケンス：フェードイン
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqFadeWait( WO_WORK * wk )
{
	if( WIPE_SYS_EndCheck() == TRUE ){
		return wk->next_seq;
	}
	return SEQ_FADE_WAIT;
}


//--------------------------------------------------------------------------------------------
/**
 * シーケンス：入力　決定位置操作実行
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqSelectDecide(WO_WORK* wk)
{
	//戻る
	if(wk->cur_pos == CPOS_BACK){
		Snd_SePlay( WO_SE_CANCEL );
		WO_SelCursorChange( wk, wk->dat->pos, PALDW_CURSOR);
//		WO_ScrollCursorOff( wk );
		WO_TalkMsgSet( wk, MSG_END_CHECK );
		wk->ynidx = YESNO_END_CHECK;
		wk->next_seq = SEQ_YESNO_PUT;
		return SEQ_MSG_WAIT;
	}
	//ページスクロール
	if(wk->cur_pos == CPOS_PAGE_DW){
		if(wk->dat->scr + LIST_NUM >= wk->sel_max){
			return SEQ_SELECT;
		}
		wk->dat->scr += LIST_NUM;
		WO_WazaListDraw( wk );
//		WO_ScrollCursorPut( wk ,0,TRUE);
		return SEQ_SELECT;
	}
	if(wk->cur_pos == CPOS_PAGE_UP){
		if(wk->dat->scr == 0){
			return SEQ_SELECT;
		}
		wk->dat->scr -= LIST_NUM;
		WO_WazaListDraw( wk );
//		WO_ScrollCursorPut( wk ,1,TRUE);
		return SEQ_SELECT;
	}
	//覚えたい技決定
	if(wk->dat->scr + wk->dat->pos >= wk->sel_max){
		return SEQ_SELECT;
	}
	Snd_SePlay( WO_SE_DECIDE );
	WO_SelCursorChange( wk, wk->dat->pos, PALDW_CURSOR);
//	WO_ScrollCursorOff( wk );
	if( WO_WazaSetCheck( wk ) < 4 ){
		WO_TalkMsgSet( wk, MSG_SET_CHECK );
		wk->ynidx = YESNO_SET_CHECK;
		wk->next_seq = SEQ_YESNO_PUT;
	}else{
		WO_TalkMsgSet( wk, MSG_CHG_CHECK );
		wk->ynidx = YESNO_CHG_CHECK;
		wk->next_seq = SEQ_YESNO_PUT;
	}
	return SEQ_MSG_WAIT;
}

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：技選択 キー入力
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
/*
static int WO_SeqSelectKeyIn( WO_WORK * wk )
{
	u32	ret;
	u16	scr, pos;

	if(sys.trg == 0){
		return SEQ_SELECT;
	}
	if(sys.trg & PAD_BUTTON_CANCEL){
		wk->cur_pos = CPOS_BACK;
		wk->cpos_y = LIST_NUM;
		wk->cpos_x = 2;
		return WO_SeqSelectDecide(wk);
	}
	if(sys.trg & PAD_BUTTON_DECIDE){
		return WO_SeqSelectDecide(wk);
	}

	if(!(sys.trg & (PAD_KEY_UP|PAD_KEY_DOWN|PAD_KEY_LEFT|PAD_KEY_RIGHT))){
		return SEQ_SELECT;
	}
	Snd_SePlay( WO_SE_LIST_MOVE );

	if(sys.trg & PAD_KEY_UP){
		wk->cpos_y = (wk->cpos_y+(CPOS_YMAX-1))%CPOS_YMAX;
	}else if(sys.trg & PAD_KEY_DOWN){
		wk->cpos_y = (wk->cpos_y+1)%CPOS_YMAX;
	}else if(sys.trg & PAD_KEY_LEFT){
		if(wk->cpos_y < LIST_NUM){
			return SEQ_SELECT;
		}
		wk->cpos_x = (wk->cpos_x+(CPOS_XMAX-1))%CPOS_XMAX;
	}else if(sys.trg & PAD_KEY_RIGHT){
		if(wk->cpos_y < LIST_NUM){
			return SEQ_SELECT;
		}
		wk->cpos_x = (wk->cpos_x+1)%CPOS_XMAX;
	}
	if(wk->cpos_y < LIST_NUM){
		wk->cur_pos = wk->cpos_y;
		wk->dat->pos = wk->cpos_y;
	}else{
		wk->cur_pos = wk->cpos_x+wk->cpos_y;
	}
	if(wk->cpos_y < LIST_NUM && (wk->dat->scr+wk->cpos_y) < wk->sel_max){
		BattleWazaParamPut( wk, WO_SelWazaGet( wk ));
	}else{
		BattleWazaParamPut( wk, 0);
	}
	WO_SelCursorChange( wk, wk->cur_pos, PALDW_CURSOR);
	return SEQ_SELECT;
}
*/

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：技選択 タッチ入力
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
/*
static int WO_SeqSelectTouchIn( WO_WORK * wk )
{
	u32	ret;
	u16	pat;

	static const RECT_HIT_TBL TpRect[] = {
//		{0,191,0,255}, ty,by,lx,rx
		{TP_WAZA1_PY,TP_WAZA1_PY+TP_WAZA_SY,TP_WAZA_PX,TP_WAZA_PX+TP_WAZA_SX},
		{TP_WAZA2_PY,TP_WAZA2_PY+TP_WAZA_SY,TP_WAZA_PX,TP_WAZA_PX+TP_WAZA_SX},
		{TP_WAZA3_PY,TP_WAZA3_PY+TP_WAZA_SY,TP_WAZA_PX,TP_WAZA_PX+TP_WAZA_SX},
		{TP_WAZA4_PY,TP_WAZA4_PY+TP_WAZA_SY,TP_WAZA_PX,TP_WAZA_PX+TP_WAZA_SX},
		{TP_SB_PY,TP_SB_PY+TP_SB_SY,TP_SBD_PX,TP_SBD_PX+TP_SB_SX},
		{TP_SB_PY,TP_SB_PY+TP_SB_SY,TP_SBU_PX,TP_SBU_PX+TP_SB_SX},
		{TP_BACK_PY,TP_BACK_PY+TP_BACK_SY,TP_BACK_PX,TP_BACK_PX+TP_BACK_SX},
		{TP_ABTN_PY,TP_ABTN_PY+TP_ABTN_SY,TP_ABTN_PX,TP_ABTN_PX+TP_ABTN_SX},
		{RECT_HIT_END,0,0,0}
	};

	ret = GF_TP_RectHitTrg(TpRect);
	if(	ret == RECT_HIT_NONE){
		return SEQ_SELECT;
	}
	Snd_SePlay( WO_SE_LIST_MOVE );
	switch(ret){
	case CPOS_ABTN:		//決定
		if(	(wk->dat->scr+wk->dat->pos) >= wk->sel_max ||
			(wk->cur_pos > CPOS_LIST04)){
			return SEQ_SELECT;
		}
		return WO_SeqSelectDecide(wk);
	case CPOS_BACK:
		pat = 0xFFFA;	//1111 1111 1111 1010	無効パレットbit(onになっている色Noのみ反応)
		if(GF_BGL_DotCheck(wk->bgl,SFRM_BACK,sys.tp_x,sys.tp_y,&pat) == FALSE){
			return SEQ_SELECT	;
		}
		wk->cur_pos = CPOS_BACK;
		wk->cpos_y = LIST_NUM;
		wk->cpos_x = ret-LIST_NUM;
		break;
	case CPOS_PAGE_DW:
	case CPOS_PAGE_UP:
		wk->cpos_y = LIST_NUM;
		wk->cpos_x = ret-LIST_NUM;
		wk->cur_pos = LIST_NUM+wk->cpos_x;
		BattleWazaParamPut( wk, 0);
		WO_AButtonDraw(wk);
		WO_WazaListDraw(wk);
		break;
	default:
		wk->dat->pos = wk->cpos_y = wk->cur_pos = ret;
		wk->cpos_x = 0;
		if((wk->dat->scr+wk->cpos_y) < wk->sel_max){
			BattleWazaParamPut( wk, WO_SelWazaGet( wk ));
		}else{
			BattleWazaParamPut( wk, 0);
		}
		WO_AButtonDraw(wk);
		WO_WazaListDraw(wk);
		return SEQ_SELECT;
	}
	return WO_SeqSelectDecide(wk);
}
*/

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：技選択　キーorタッチ表示状態セット
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static void WO_InputModeChange( WO_WORK * wk )
{
	if(wk->key_mode == APP_KTST_TOUCH){
		CATS_ObjectEnableCap( wk->cap[WO_CLA_CURSOR], FALSE);
	}else{
		CATS_ObjectEnableCap( wk->cap[WO_CLA_CURSOR], TRUE);
		WO_SelCursorChange( wk, wk->cur_pos, PALDW_CURSOR);
	}
	WO_AButtonDraw(wk);
	WO_WazaListDraw(wk);
}

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：技選択　キーorタッチ切替
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqSelectInputCheck( WO_WORK * wk )
{
	if(wk->key_mode == APP_KTST_TOUCH){
		if(GF_TP_GetCont() != 0){	//
			return FALSE;
		}
		if(sys.cont != 0){
			wk->key_mode = APP_KTST_KEY;
			WO_InputModeChange(wk);
			return TRUE;
		}
	}else{
		if(sys.cont != 0){
			return FALSE;
		}
		if(GF_TP_GetCont() != 0){
			wk->key_mode = APP_KTST_TOUCH;
			WO_InputModeChange(wk);
			return FALSE;
		}
	}
	return FALSE;
}

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：技選択
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqSelect( WO_WORK * wk )
{
	u32	ret;

	wk->cm_pos = CURSORMOVE_PosGet( wk->cmwk );		// 前回の位置保存
	ret = CURSORMOVE_MainCont( wk->cmwk );

	switch( ret ){
	case 0:		// 技１
	case 1:		// 技２
	case 2:		// 技３
	case 3:		// 技４
		if( GF_TP_GetTrg() == FALSE ){
			if( wk->dat->scr + ret < wk->sel_max ){
				Snd_SePlay( WO_SE_DECIDE );
				WazaSelBgChange( wk, ret );
				return WazaSelectEnter( wk );
			}
		}else{
			if( wk->dat->scr + ret < wk->sel_max ){
				Snd_SePlay( WO_SE_LIST_MOVE );
				WazaSelBgChange( wk, ret );
			}else{
				WazaSelBgChange( wk, 5 );
			}
		}
		break;

	case 4:		// 下矢印
//		Snd_SePlay( WO_SE_PAGE_MOVE );
//		ScrollButtonOnOff( wk );
		break;

	case 5:		// 上矢印
//		Snd_SePlay( WO_SE_PAGE_MOVE );
		break;

	case 6:						// もどる
	case CURSORMOVE_CANCEL:		// キャンセル
		Snd_SePlay( WO_SE_CANCEL );
		WazaSelBgChange( wk, 5 );
		EnterButtonOnOff( wk, FALSE );	// 決定を消す
/*
//		WO_SelCursorChange( wk, wk->dat->pos, PALDW_CURSOR);
//		WO_ScrollCursorOff( wk );
		WO_TalkMsgSet( wk, MSG_END_CHECK );
		wk->ynidx = YESNO_END_CHECK;
		wk->next_seq = SEQ_YESNO_PUT;
		return SEQ_MSG_WAIT;
*/
		return RetButtonAnmInit( wk, SEQ_RET_BUTTON );


	case 7:		// おぼえる
		Snd_SePlay( WO_SE_DECIDE );
		return EnterButtonAnmInit( wk, SEQ_ENTER_BUTTON );

	case CURSORMOVE_CURSOR_MOVE:	// 移動
//		Snd_SePlay( WO_SE_LIST_MOVE );
		break;

	case CURSORMOVE_CURSOR_ON:		// カーソル表示
	case CURSORMOVE_NONE:			// 動作なし
		break;
	}

	return SEQ_SELECT;

/*
	if(WO_SeqSelectInputCheck(wk)){
		return SEQ_SELECT;
	}
	if(wk->key_mode == APP_KTST_KEY){
		return WO_SeqSelectKeyIn( wk );
	}else{
		return WO_SeqSelectTouchIn( wk );
	}
*/
}

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：メッセージ終了待ち
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqMsgWait( WO_WORK * wk )
{
	if( GF_MSG_PrintEndCheck( wk->midx ) == 0 ){
		return wk->next_seq;
	}
	return SEQ_MSG_WAIT;
}

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：はい・いいえ表示
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqYesNoPut( WO_WORK * wk )
{
	TOUCH_SW_PARAM param;
	MI_CpuClear8(&param,sizeof(TOUCH_SW_PARAM));

	param.p_bgl  = wk->bgl;
	param.bg_frame = SFRM_MSG;
	param.char_offs = WO_YESNO_WIN_CGX;
	param.pltt_offs = WO_PAL_YESNO_WIN;
	param.x		= WO_YESNO_WIN_PX;
	param.y		= WO_YESNO_WIN_PY;
	param.kt_st = wk->key_mode;
	param.key_pos = 0;
	TOUCH_SW_Init( wk->ynbtn_wk, &param);
	PassiveSet( TRUE );
	return SEQ_YESNO_WAIT;
}

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：はい・いいえ処理
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqYesNoWait( WO_WORK * wk )
{
	u32 ret,key_mode;

	ret = TOUCH_SW_Main( wk->ynbtn_wk );
	switch(ret){
	case TOUCH_SW_RET_YES:
		ret = YesNoFunc[wk->ynidx].yes( wk );
		PassiveSet( FALSE );
		break;
	case TOUCH_SW_RET_NO:
		ret = YesNoFunc[wk->ynidx].no( wk );
		PassiveSet( FALSE );
		break;
	default:
		return SEQ_YESNO_WAIT;
	}
	//現在の操作モードを取得
	wk->key_mode = TOUCH_SW_GetKTStatus(wk->ynbtn_wk);
//	WO_InputModeChange(wk);
	TOUCH_SW_Reset( wk->ynbtn_wk);
	return ret;
}

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：技セット
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqWazaSet( WO_WORK * wk )
{
	u32	buf;

	buf = WO_SelWazaGet( wk );
	PokeParaPut( wk->dat->pp, ID_PARA_waza1+wk->dat->del_pos, &buf );
	buf = 0;
	PokeParaPut( wk->dat->pp, ID_PARA_pp_count1+wk->dat->del_pos, &buf );
	buf = WT_PPMaxGet( WO_SelWazaGet(wk), 0 );
	PokeParaPut( wk->dat->pp, ID_PARA_pp1+wk->dat->del_pos, &buf );

	wk->dat->ret = WAZAOSHIE_RET_SET;
	return SEQ_FADEOUT_SET;
}

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：技セット完了メッセージセット
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqWazaDelSet( WO_WORK * wk )
{
	WO_TalkMsgSet( wk, MSG_CHG_WAZA );
	wk->next_seq = SEQ_WAZA_SET;
	return SEQ_MSG_WAIT;
}

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：技選択チェック
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqDelCheck( WO_WORK * wk )
{
	if( wk->dat->del_pos < 4 ){
		WO_TalkMsgSet( wk, MSG_DEL_ENTER );
		wk->ynidx = YESNO_DEL_ENTER;
	}else{
		WO_TalkMsgSet( wk, MSG_DEL_CHECK );
		wk->ynidx = YESNO_DEL_CHECK;
	}
	wk->next_seq = SEQ_YESNO_PUT;

	return SEQ_MSG_WAIT;
}

//--------------------------------------------------------------------------------------------
/**
 * シーケンス：フェードアウトセット
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqFadeOutSet( WO_WORK * wk )
{
	APP_WipeStart( APP_WIPE_OUT, HEAPID_WAZAOSHIE );
	wk->next_seq = SEQ_END;
	return SEQ_FADE_WAIT;
}


//--------------------------------------------------------------------------------------------
/**
 * ページ切り替え
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_PageChange( WO_WORK * wk )
{
	u16	waza;

	waza = WO_SelWazaGet( wk );

	if( waza != WAZAOSHIE_TBL_MAX ){
		BattleWazaParamPut( wk, waza );
	}else{
		BattleWazaParamPut( wk, BMPLIST_CANCEL );
	}
	WO_TypeIconInit( wk );
}

//--------------------------------------------------------------------------------------------
/**
 * 文字表示
 *
 * @param	wk		ワーク
 * @param	widx	ウィンドウインデックス
 * @param	fnt		表示フォント
 * @param	col		表示カラー
 * @param	mode	表示モード
 * @param	py		y方向オフセット
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void StrPut( WO_WORK * wk, u32 widx, u32 fnt, u32 col, u32 mode, u8 py )
{
	u8	siz;
	u8	wsx;
	u8	px;

	switch( mode ){
	case STR_MODE_LEFT:		// 左詰め
		px = 0;
		break;
	case STR_MODE_RIGHT:	// 右詰め
		siz = FontProc_GetPrintStrWidth( FONT_SYSTEM, wk->mbuf, 0 );
		wsx = GF_BGL_BmpWinGet_SizeX( &wk->win[widx] ) * 8;
		px  = wsx - siz;
		break;
	case STR_MODE_CENTER:	// 中央
		siz = FontProc_GetPrintStrWidth( FONT_SYSTEM, wk->mbuf, 0 );
		wsx = GF_BGL_BmpWinGet_SizeX( &wk->win[widx] ) * 8;
		px  = (wsx-siz)/2;
		break;
	}
	GF_STR_PrintColor( &wk->win[widx], fnt, wk->mbuf, px, py, MSG_NO_PUT, col, NULL );
}

//--------------------------------------------------------------------------------------------
/**
 * 数字入り文字列展開
 *
 * @param	wk		ワーク
 * @param	msg_id	メッセージID
 * @param	num		数字
 * @param	keta	桁
 * @param	type	表示タイプ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void NumPrmSet( WO_WORK * wk, u32 msg_id, u32 num, u8 keta, u8 type )
{
	STRBUF * str;

	str = MSGMAN_AllocString( wk->mman, msg_id );
	WORDSET_RegisterNumber( wk->wset, 0, num, keta, type, NUMBER_CODETYPE_DEFAULT );
	WORDSET_ExpandStr( wk->wset, wk->mbuf, str );
	STRBUF_Delete( str );
}


//--------------------------------------------------------------------------------------------
/**
 * 固定文字列描画
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_DefStrWrite( WO_WORK * wk )
{
	STRBUF	*str;
	MSGDATA_MANAGER * waza_man;
	POKEMON_PASO_PARAM* ppp;
	u32	siz,i;

	//　せつめい
	MSGMAN_GetString( wk->mman, msg_waza_oboe_exp_01, wk->mbuf );
	StrPut( wk, WIN_EXP, FONT_SYSTEM, WOFCOL_N_BLACK, STR_MODE_LEFT ,4);
	GF_BGL_BmpWinOnVReq( &wk->win[WIN_EXP] );

	//　もどる
	MSGMAN_GetString( wk->mman, msg_exp_decide, wk->mbuf );
	StrPut( wk, WIN_ABTN, FONT_TOUCH, WOFCOL_N_WHITE, STR_MODE_CENTER ,4);

	//　もどる
	MSGMAN_GetString( wk->mman, msg_exp_back, wk->mbuf );
	StrPut( wk, WIN_BACK, FONT_TOUCH, WOFCOL_N_WHITE, STR_MODE_CENTER ,4);
	GF_BGL_BmpWinOnVReq( &wk->win[WIN_BACK] );


	// 「ぶんるい」
	MSGMAN_GetString( wk->mman, msg_waza_oboe_01_01, wk->mbuf );
	StrPut( wk, WIN_STR_CLASS, FONT_SYSTEM, WOFCOL_N_WHITE, STR_MODE_LEFT ,0);
	GF_BGL_BmpWinOnVReq( &wk->win[WIN_STR_CLASS] );

	// 「いりょく」
	MSGMAN_GetString( wk->mman, msg_waza_oboe_01_02, wk->mbuf );
	StrPut( wk, WIN_STR_ATTACK, FONT_SYSTEM, WOFCOL_N_WHITE, STR_MODE_LEFT ,0);
	GF_BGL_BmpWinOnVReq( &wk->win[WIN_STR_ATTACK] );

	// 「めいちゅう」
	MSGMAN_GetString( wk->mman, msg_waza_oboe_01_03, wk->mbuf );
	StrPut( wk, WIN_STR_HIT, FONT_SYSTEM, WOFCOL_N_WHITE, STR_MODE_LEFT ,0);
	GF_BGL_BmpWinOnVReq( &wk->win[WIN_STR_HIT] );

	///////////////////////////////////////////////////////////////////////////
	//上画面
	str = STRBUF_Create( TMP_MSGBUF_SIZ, HEAPID_WAZAOSHIE );

	//タイトル
	MSGMAN_GetString( wk->mman, msg_param_exp, str );
	WORDSET_RegisterPokeNickName( wk->wset, 0, PPPPointerGet(wk->dat->pp) );
	WORDSET_ExpandStr( wk->wset, wk->mbuf, str );
	StrPut( wk, WIN_TITLE, FONT_SYSTEM, WOFCOL_N_BLACK, STR_MODE_LEFT ,4);
	GF_BGL_BmpWinOnVReq( &wk->win[WIN_TITLE] );

	waza_man = MSGMAN_Create(
			MSGMAN_TYPE_NORMAL, ARC_MSG, NARC_msg_wazaname_dat, HEAPID_WAZAOSHIE );
	ppp = PPPPointerGet(wk->dat->pp);

	//技リスト
	for(i = 0;i < 4;i++){
		u16 waza = PokePasoParaGet(ppp,ID_PARA_waza1+i,NULL);
		if(waza == 0){
			CATS_ObjectEnableCap( wk->cap[WO_CLA_TYPE5+i], 0 );
			continue;
		}else{
			CATS_ObjectEnableCap( wk->cap[WO_CLA_TYPE5+i], 1 );
			WO_TypeIconChange( wk,waza, i+LIST_NUM );
		}
		//技名
		MSGMAN_GetString( waza_man, waza , wk->mbuf );
		StrPut( wk, WIN_MWAZA, FONT_SYSTEM, WOFCOL_N_WHITE, STR_MODE_LEFT ,32*i);

		//PP
		GF_STR_PrintColor( &wk->win[WIN_MWAZA], FONT_SYSTEM, wk->pp1_str,
			F_WLIST_PP1_OX, 32*i+16, MSG_NO_PUT, WOFCOL_N_BLACK, NULL );

		//PP/MPP
		WORDSET_RegisterNumber( wk->wset, 0,
			PokePasoParaGet(ppp,ID_PARA_pp1+i,NULL),2, NUM_MODE_SPACE, NUMBER_CODETYPE_DEFAULT );
		WORDSET_RegisterNumber( wk->wset, 1,
			PokePasoParaGet(ppp,ID_PARA_pp_max1+i,NULL),2, NUM_MODE_LEFT, NUMBER_CODETYPE_DEFAULT );
		WORDSET_ExpandStr( wk->wset, wk->mbuf, wk->pp2_str );
		GF_STR_PrintColor( &wk->win[WIN_MWAZA], FONT_SYSTEM, wk->mbuf,
			F_WLIST_PP2_OX, 32*i+16, MSG_NO_PUT, WOFCOL_N_BLACK, NULL );
	}
	GF_BGL_BmpWinOnVReq( &wk->win[WIN_MWAZA] );

	//ポケモン名他
	MSGMAN_GetString( wk->mman, msg_param_name, str );
	WORDSET_RegisterPokeMonsName(wk->wset,0,ppp );
	WORDSET_ExpandStr( wk->wset, wk->mbuf, str );
	GF_STR_PrintColor( &wk->win[WIN_MPRM], FONT_SYSTEM, wk->mbuf,
			F_WLIST_NAME_OX, 0, MSG_NO_PUT, WOFCOL_N_BLACK, NULL );

	MSGMAN_GetString( wk->mman, msg_param_level, str );
	WORDSET_RegisterNumber( wk->wset, 0,
			PokePasoParaGet(ppp,ID_PARA_level,NULL),3, NUM_MODE_SPACE, NUMBER_CODETYPE_DEFAULT );
	WORDSET_ExpandStr( wk->wset, wk->mbuf, str );
//	GF_STR_PrintColor( &wk->win[WIN_MPRM], FONT_SYSTEM, wk->mbuf,
//			F_WLIST_LEVEL_OX, 16, MSG_NO_PUT, WOFCOL_N_BLACK, NULL );
	StrPut( wk, WIN_MPRM, FONT_SYSTEM, WOFCOL_N_BLACK, STR_MODE_RIGHT ,16);

	GF_BGL_BmpWinOnVReq( &wk->win[WIN_MPRM] );

	MSGMAN_Delete( waza_man );

	STRBUF_Delete(str);
}


//--------------------------------------------------------------------------------------------
/**
 * 技数取得
 *
 * @param	wk		ワーク
 *
 * @return	技数
 */
//--------------------------------------------------------------------------------------------
static u32 WO_WazaTableNumGet( WO_WORK * wk )
{
	u32	i;

	for( i=0; i<256; i++ ){
		if( wk->dat->waza_tbl[i] == WAZAOSHIE_TBL_MAX ){
			break;
		}
	}
	return i;
}

//--------------------------------------------------------------------------------------------
/**
 * サブ画面パーツ描画
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_SubBGPartsDraw( WO_WORK * wk ,u8 px,u8 py,u8 sx, u8 sy,u8 ox,u8 oy)
{
	GF_BGL_ScrWriteExpand(wk->bgl,SFRM_BACK,
		px,py,sx,sy,wk->pSDParts->rawData,ox,oy,
		wk->pSDParts->screenWidth/8,wk->pSDParts->screenHeight/8);
	GF_BGL_LoadScreenV_Req( wk->bgl, SFRM_BACK );
}

//--------------------------------------------------------------------------------------------
/**
 * 技リスト ライン描画
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_WazaListLineDraw( WO_WORK * wk ,u8 scr,u8 pos)
{
	u32 tmp,py;

	py = pos*LIST_SY;
	tmp = 0;

	if(scr+pos >= wk->sel_max){
		WO_SubBGPartsDraw(wk,BG_WLIST_PX,WIN_LIST_PY+(pos*BG_WLIST_SY),
			BG_WLIST_SX,BG_WLIST_SY,BG_WLIST_SPX,BG_WLIST_SPY+BG_WLIST_SY);
		return;
/*
	}else{
		if(wk->key_mode == APP_KTST_TOUCH && wk->cur_pos == pos){
			tmp = 1;
		}
		WO_SubBGPartsDraw(wk,BG_WLIST_PX,WIN_LIST_PY+(pos*BG_WLIST_SY),
			BG_WLIST_SX,BG_WLIST_SY,BG_WLIST_SPX,BG_WLIST_SPY+(BG_WLIST_SY*tmp*2));
*/
	}

	//技名描画
	GF_STR_PrintColor( &wk->win[WIN_LIST],FONT_SYSTEM,wk->ld[scr+pos].str,
			0, py, MSG_NO_PUT, WOFCOL_N_WHITE, NULL );

	//PP
	GF_STR_PrintColor( &wk->win[WIN_LIST], FONT_SYSTEM, wk->pp1_str,F_WLIST_PP1_OX, py+16, MSG_NO_PUT, WOFCOL_N_BLACK, NULL );

	// PP/MPP
	tmp = WT_PPMaxGet( wk->ld[scr+pos].param, 0 );
	WORDSET_RegisterNumber( wk->wset, 0, tmp,2, NUM_MODE_SPACE, NUMBER_CODETYPE_DEFAULT );
	WORDSET_RegisterNumber( wk->wset, 1, tmp,2, NUM_MODE_LEFT, NUMBER_CODETYPE_DEFAULT );
	WORDSET_ExpandStr( wk->wset, wk->mbuf, wk->pp2_str );
	GF_STR_PrintColor( &wk->win[WIN_LIST], FONT_SYSTEM, wk->mbuf,
			F_WLIST_PP2_OX, py+16, MSG_NO_PUT, WOFCOL_N_BLACK, NULL );
}

//--------------------------------------------------------------------------------------------
/**
 * 技リスト ページ描画
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_WazaListDraw( WO_WORK * wk )
{
	u32 i;

	//領域クリア
	GF_BGL_BmpWinDataFill(&wk->win[WIN_LIST],0);

	for(i = 0;i < LIST_NUM;i++){
		WO_WazaListLineDraw(wk ,wk->dat->scr,i);
	}
	//ウィンドウプット
	GF_BGL_BmpWinOnVReq(&(wk->win[WIN_LIST]));
	GF_BGL_LoadScreenV_Req( wk->bgl, SFRM_BACK );

	WO_TypeIconInit( wk );
}


//--------------------------------------------------------------------------------------------
/**
 * 技リスト作成
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_WazaListMake( WO_WORK * wk )
{
	MSGDATA_MANAGER * mman;
	BMPLIST_HEADER	lh;
	u32	i;

	wk->sel_max = (u8)WO_WazaTableNumGet( wk );

	wk->ld = BMP_MENULIST_Create( wk->sel_max, HEAPID_WAZAOSHIE );
	i = wk->ld[0].param;

	mman = MSGMAN_Create(
			MSGMAN_TYPE_NORMAL, ARC_MSG, NARC_msg_wazaname_dat, HEAPID_WAZAOSHIE );

	for( i=0; i<wk->sel_max; i++ ){
		if( wk->dat->waza_tbl[i] != WAZAOSHIE_TBL_MAX ){
			BMP_MENULIST_AddArchiveString(
				wk->ld, mman, wk->dat->waza_tbl[i], wk->dat->waza_tbl[i] );
		}else{
			BMP_MENULIST_AddArchiveString(
				wk->ld, wk->mman, msg_waza_oboe_01_11, BMPLIST_CANCEL );
			break;
		}
	}

	MSGMAN_Delete( mman );
	wk->cpos_x = 0;
	wk->cpos_y = wk->dat->pos;
	WO_WazaListDraw( wk );
}

//--------------------------------------------------------------------------------------------
/**
 * 技リスト削除
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_WazaListExit( WO_WORK * wk )
{
	BMP_MENULIST_Delete( wk->ld );
}

//--------------------------------------------------------------------------------------------
/**
 * 決定ボタン描画
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_AButtonDraw( WO_WORK * wk )
{
/*
	u16 ox;
	if(	wk->key_mode == APP_KTST_KEY ||
		(wk->dat->scr+wk->dat->pos >= wk->sel_max) ||
		wk->cur_pos >= LIST_NUM){
		GF_BGL_BmpWinOffVReq( &wk->win[WIN_ABTN] );
		ox = BG_ABTN_OX;
	}else{
		GF_BGL_BmpWinOnVReq( &wk->win[WIN_ABTN] );
		ox = BG_ABTN_OX+BG_ABTN_SX;
	}
	WO_SubBGPartsDraw(wk,BG_ABTN_PX,BG_ABTN_PY,
		BG_ABTN_SX,BG_ABTN_SY,ox,BG_ABTN_OY);
*/
}


//--------------------------------------------------------------------------------------------
/**
 * 戦闘技パラメータ表示
 *
 * @param	wk		ワーク
 * @param	prm		BMPリストデータ（主に技番号）
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BattleWazaParamPut( WO_WORK * wk, u32 prm )
{
	GF_BGL_BmpWinDataFill( &wk->win[WIN_BTL_INFO], 0 );
	GF_BGL_BmpWinDataFill( &wk->win[WIN_PRM_ATTACK], 0 );
	GF_BGL_BmpWinDataFill( &wk->win[WIN_PRM_HIT], 0 );

	CATS_ObjectEnableCap( wk->cap[WO_CLA_KIND], 0 );

	if( prm != BMPLIST_CANCEL ){
		MSGDATA_MANAGER * mman;
		u32	tmp;

		// 威力
		tmp = WT_WazaDataParaGet( prm, ID_WTD_damage );
		if( tmp <= 1 ){
			MSGMAN_GetString( wk->mman, msg_waza_oboe_01_12, wk->mbuf );
		}else{
			NumPrmSet( wk, msg_waza_oboe_01_08, tmp, 3, NUM_MODE_LEFT );
		}
		StrPut( wk, WIN_PRM_ATTACK, FONT_SYSTEM, WOFCOL_N_BLACK, STR_MODE_RIGHT ,0);

		// 命中
		tmp = WT_WazaDataParaGet( prm, ID_WTD_hitprobability );
		if( tmp == 0 ){
			MSGMAN_GetString( wk->mman, msg_waza_oboe_01_12, wk->mbuf );
		}else{
			NumPrmSet( wk, msg_waza_oboe_01_09, tmp, 3, NUM_MODE_LEFT );
		}
		StrPut( wk, WIN_PRM_HIT, FONT_SYSTEM, WOFCOL_N_BLACK, STR_MODE_RIGHT ,0);

		// 説明
		mman = MSGMAN_Create(
				MSGMAN_TYPE_DIRECT, ARC_MSG, NARC_msg_wazainfo_dat, HEAPID_WAZAOSHIE );
		MSGMAN_GetString( mman, prm, wk->mbuf );
		StrPut( wk, WIN_BTL_INFO, FONT_SYSTEM, WOFCOL_N_BLACK, STR_MODE_LEFT ,0);
		MSGMAN_Delete( mman );

		WO_KindIconChange( wk, prm );
		CATS_ObjectEnableCap( wk->cap[WO_CLA_KIND], 1 );

		GF_BGL_BmpWinOnVReq( &wk->win[WIN_STR_CLASS] );
		GF_BGL_BmpWinOnVReq( &wk->win[WIN_STR_ATTACK] );
		GF_BGL_BmpWinOnVReq( &wk->win[WIN_STR_HIT] );
	}else{
		GF_BGL_BmpWinOffVReq( &wk->win[WIN_STR_CLASS] );
		GF_BGL_BmpWinOffVReq( &wk->win[WIN_STR_ATTACK] );
		GF_BGL_BmpWinOffVReq( &wk->win[WIN_STR_HIT] );
	}

	GF_BGL_BmpWinOnVReq( &wk->win[WIN_BTL_INFO] );
	GF_BGL_BmpWinOnVReq( &wk->win[WIN_PRM_ATTACK] );
	GF_BGL_BmpWinOnVReq( &wk->win[WIN_PRM_HIT] );
}

//--------------------------------------------------------------------------------------------
/**
 * メッセージ作成
 *
 * @param	wk		ワーク
 * @param	id		メッセージID
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_MsgMake( WO_WORK * wk, u32 id )
{
	STRBUF * str;

	switch( id ){
	case MSG_SEL_WAZA:	// @0に　どのわざを　おぼえさせる？
		WORDSET_RegisterPokeNickName( wk->wset, 0, PPPPointerGet(wk->dat->pp) );
		break;
	case MSG_SET_CHECK:	// @1　を  おぼえさせますか？
		WORDSET_RegisterWazaName( wk->wset, 1, WO_SelWazaGet( wk ) );
		break;
	case MSG_END_CHECK:	// @0に　わざを  おぼえさせるのを　あきらめますか？
		WORDSET_RegisterPokeNickName( wk->wset, 0, PPPPointerGet(wk->dat->pp) );
		break;
	case MSG_SET_WAZA:	// @0は　あたらしく　@1を　おぼえた！▼"
		WORDSET_RegisterPokeNickName( wk->wset, 0, PPPPointerGet(wk->dat->pp) );
		WORDSET_RegisterWazaName( wk->wset, 1, WO_SelWazaGet( wk ) );
		break;
	case MSG_CHG_CHECK:	// @0は　あたらしく　@1を　おぼえたい……▼　しかし　〜
		WORDSET_RegisterPokeNickName( wk->wset, 0, PPPPointerGet(wk->dat->pp) );
		WORDSET_RegisterWazaName( wk->wset, 1, WO_SelWazaGet( wk ) );
		break;
	case MSG_DEL_WAZA:	// １　２の……　ポカン！▼　@0は　@1の つかいかたを　〜
		WORDSET_RegisterPokeNickName( wk->wset, 0, PPPPointerGet(wk->dat->pp) );
		WORDSET_RegisterWazaName( wk->wset, 1, WO_DelWazaGet( wk ) );
		break;
	case MSG_CHG_WAZA:	// @0は　あたらしく @1を　おぼえた！▼
		WORDSET_RegisterPokeNickName( wk->wset, 0, PPPPointerGet(wk->dat->pp) );
		WORDSET_RegisterWazaName( wk->wset, 1, WO_SelWazaGet( wk ) );
		break;
	case MSG_DEL_CHECK:	// それでは……　@1を　おぼえるのを　あきらめますか？
		WORDSET_RegisterWazaName( wk->wset, 1, WO_SelWazaGet( wk ) );
		break;
	case MSG_CANCEL:	// @0は　@1を　おぼえずに　おわった！▼
		WORDSET_RegisterPokeNickName( wk->wset, 0, PPPPointerGet(wk->dat->pp) );
		WORDSET_RegisterWazaName( wk->wset, 1, WO_SelWazaGet( wk ) );
		break;
	case MSG_SUB_ITEM:	// @2は　おれいに　ハートのウロコを　１まい　あげた！▼
		WORDSET_RegisterPlayerName( wk->wset, 2, wk->dat->myst );
		break;
	case MSG_DEL_ENTER:	// @0を　わすれさせて　よろしいですね？
		WORDSET_RegisterWazaName( wk->wset, 0, WO_DelWazaGet( wk ) );
		break;
	}

	str = MSGMAN_AllocString( wk->mman, MsgDataTbl[wk->dat->mode][id] );
	WORDSET_ExpandStr( wk->wset, wk->mbuf, str );
	STRBUF_Delete( str );
}

//--------------------------------------------------------------------------------------------
/**
 * 覚える技を取得
 *
 * @param	wk		ワーク
 *
 * @return	覚える技
 */
//--------------------------------------------------------------------------------------------
static u16 WO_SelWazaGet( WO_WORK * wk )
{
	return wk->dat->waza_tbl[ wk->dat->scr + wk->dat->pos ];
}

//--------------------------------------------------------------------------------------------
/**
 * 忘れる技取得
 *
 * @param	wk		ワーク
 *
 * @return	忘れる技
 */
//--------------------------------------------------------------------------------------------
static u16 WO_DelWazaGet( WO_WORK * wk )
{
	return (u16)PokeParaGet( wk->dat->pp, ID_PARA_waza1+wk->dat->del_pos, NULL );
}

//--------------------------------------------------------------------------------------------
/**
 * 会話（風）メッセージ表示
 *
 * @param	wk		ワーク
 * @param	id		メッセージID
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_TalkMsgSet( WO_WORK * wk, u32 id )
{
	GF_BGL_BmpWinDataFill( &wk->win[WIN_MSG], 15 );
	BmpTalkWinWrite( &wk->win[WIN_MSG], WINDOW_TRANS_ON, WO_TALK_WIN_CGX, WO_PAL_TALK_WIN );

	WO_MsgMake( wk, id );
	MsgPrintSkipFlagSet( MSG_SKIP_ON );
//	MsgPrintAutoFlagSet( MSG_AUTO_OFF );
//	MsgPrintAutoFlagSet( MSG_TP_RECT_ON );
	wk->midx = GF_STR_PrintSimple(
				&wk->win[WIN_MSG], FONT_TALK, wk->mbuf,
				0, 0, CONFIG_GetMsgPrintSpeed(wk->dat->cfg), WO_TalkMsgCallBack );
}

//--------------------------------------------------------------------------------------------
/**
 * 会話（風）メッセージ表示OFF
 *
 * @param	wk		ワーク
 * @param	id		メッセージID
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_TalkMsgOff( WO_WORK * wk)
{
	BmpTalkWinClear( &wk->win[WIN_MSG],WINDOW_TRANS_OFF);
	GF_BGL_BmpWinOffVReq( &wk->win[WIN_MSG]);
}

//--------------------------------------------------------------------------------------------
/**
 * 会話（風）メッセージコールバック
 *
 * @param	mph		メッセージ描画データ
 * @param	value	コールバックナンバ
 *
 * @retval	"TRUE = 待ち"
 * @retval	"FALSE = 次の処理へ"
 */
//--------------------------------------------------------------------------------------------
static BOOL WO_TalkMsgCallBack( MSG_PRINT_HEADER * mph, u16 value )
{
	switch( value ){
	case 1:		// SE終了待ち
		return Snd_SePlayCheckAll();

	case 2:		// ME終了待ち
		return Snd_MePlayCheckBgmPlay();
	case 3:		// "ポカン"
		Snd_SePlay( SEQ_SE_DP_KON );
		break;

	case 4:		// "おぼえた"
		Snd_MePlay( SEQ_ME_LVUP );
		break;

	case 5:		// "ポカン"のSE終了待ち
		return Snd_SePlayCheck( SEQ_SE_DP_KON );
	}

	return FALSE;
}

//--------------------------------------------------------------------------------------------
/**
 * 技を４つ覚えているかチェック
 *
 * @param	wk		ワーク
 *
 * @retval	"覚えている場合 = 4"
 * @retval	"覚えていない場合 = 0 〜 3"
 */
//--------------------------------------------------------------------------------------------
static u8 WO_WazaSetCheck( WO_WORK * wk )
{
	u8	i;

	for( i=0; i<4; i++ ){
		if( PokeParaGet( wk->dat->pp, ID_PARA_waza1+i, NULL ) == 0 ){
			break;
		}
	}
	return i;
}


//--------------------------------------------------------------------------------------------
/**
 * 「@1　を  おぼえさせますか？」で「はい」が選択された場合
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SetCheck_Yes( WO_WORK * wk )
{
	WO_TalkMsgSet( wk, MSG_SET_WAZA );
	wk->dat->del_pos = WO_WazaSetCheck( wk );
	wk->next_seq = SEQ_WAZA_SET;
	return SEQ_MSG_WAIT;
}
//--------------------------------------------------------------------------------------------
/**
 * 「@1　を  おぼえさせますか？」で「いいえ」が選択された場合
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SetCheck_No( WO_WORK * wk )
{
/*
	GF_BGL_BmpWinDataFill( &wk->win[WIN_MSG], 15 );
	WO_MsgMake( wk, MSG_SEL_WAZA );
	StrPut( wk, WIN_MSG, FONT_TALK, WOFCOL_W_BLACK, STR_MODE_LEFT ,0);
	GF_BGL_BmpWinOnVReq( &wk->win[WIN_MSG] );
*/
	WO_TalkMsgOff(wk);
//	WO_SelCursorChange( wk, wk->dat->pos, PALDW_CURSOR);
	if( wk->enter_flg == 0 ){
		WazaSelBgChange( wk, 5 );
	}
	return SEQ_SELECT;
}

//--------------------------------------------------------------------------------------------
/**
 * 「@0に　わざを  おぼえさせるのを　あきらめますか？」で「はい」が選択された場合
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_EndCheck_Yes( WO_WORK * wk )
{
	wk->dat->ret = WAZAOSHIE_RET_CANCEL;
	return SEQ_FADEOUT_SET;
}
//--------------------------------------------------------------------------------------------
/**
 * 「@0に　わざを  おぼえさせるのを　あきらめますか？」で「いいえ」が選択された場合
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_EndCheck_No( WO_WORK * wk )
{
#if 0
	GF_BGL_BmpWinDataFill( &wk->win[WIN_MSG], 15 );
	WO_MsgMake( wk, MSG_SEL_WAZA );
	StrPut( wk, WIN_MSG, FONT_TALK, WOFCOL_W_BLACK, STR_MODE_LEFT ,0);
	GF_BGL_BmpWinOnVReq( &wk->win[WIN_MSG] );
#endif
	WO_TalkMsgOff(wk);
//	WO_SelCursorChange( wk, wk->dat->pos, PALDW_CURSOR );
	return SEQ_SELECT;
}

//--------------------------------------------------------------------------------------------
/**
 * 「@0は　あたらしく　@1を　おぼえたい……▼　しかし　〜」で「はい」が選択された場合
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_ChgCheck_Yes( WO_WORK * wk )
{
	wk->next_seq = SEQ_PST_INIT;
	return SEQ_FADE_WAIT;
}
//--------------------------------------------------------------------------------------------
/**
 * 「@0は　あたらしく　@1を　おぼえたい……▼　しかし　〜」で「いいえ」が選択された場合
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_ChgCheck_No( WO_WORK * wk )
{
	WO_TalkMsgSet( wk, MSG_DEL_CHECK );
	wk->ynidx = YESNO_DEL_CHECK;
	wk->next_seq = SEQ_YESNO_PUT;
	return SEQ_MSG_WAIT;
}

//--------------------------------------------------------------------------------------------
/**
 * 「それでは……　@1を　おぼえるのを　あきらめますか？」で「はい」が選択された場合
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_DelCheck_Yes( WO_WORK * wk )
{
	WO_TalkMsgSet( wk, MSG_CANCEL );
	wk->next_seq = SEQ_FADEOUT_SET;
	wk->dat->ret = WAZAOSHIE_RET_CANCEL;
	return SEQ_MSG_WAIT;
}
//--------------------------------------------------------------------------------------------
/**
 * 「それでは……　@1を　おぼえるのを　あきらめますか？」で「いいえ」が選択された場合
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_DelCheck_No( WO_WORK * wk )
{
	WO_TalkMsgSet( wk, MSG_CHG_CHECK );
	wk->ynidx = YESNO_CHG_CHECK;
	wk->next_seq = SEQ_YESNO_PUT;
	return SEQ_MSG_WAIT;
}

//--------------------------------------------------------------------------------------------
/**
 * 「@0を　わすれさせて　よろしいですね？」で「はい」が選択された場合
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_DelEnter_Yes( WO_WORK * wk )
{
	WO_TalkMsgSet( wk, MSG_DEL_WAZA );
	wk->next_seq = SEQ_WAZADEL_SET;
	return SEQ_MSG_WAIT;
}
//--------------------------------------------------------------------------------------------
/**
 * 「@0を　わすれさせて　よろしいですね？」で「いいえ」が選択された場合
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_DelEnter_No( WO_WORK * wk )
{
	wk->next_seq = SEQ_PST_INIT;
	return SEQ_FADE_WAIT;
}



//============================================================================================
//	セルアクター
//============================================================================================

//--------------------------------------------------------------------------------------------
/**
 * リソースマネージャー初期化
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_ClactResManInit( WO_WORK * wk )
{
	TCATS_RESOURCE_NUM_LIST	crnl = {
		WO_CHR_ID_MAX, WO_PAL_ID_MAX, WO_CEL_ID_MAX, WO_ANM_ID_MAX, 0, 0
	};

	initVramTransferManagerHeap( 64, HEAPID_WAZAOSHIE );

	wk->csp = CATS_AllocMemory( HEAPID_WAZAOSHIE );
	wk->crp = CATS_ResourceCreate( wk->csp );
	{
		TCATS_OAM_INIT	coi = {
			0, 128,
			0, 32,
			0, 128,
			0, 32,
		};
		TCATS_CHAR_MANAGER_MAKE ccmm = {
			WO_CLA_MAX,
			1024*16,
			1024*16,
			GX_OBJVRAMMODE_CHAR_1D_32K,
			GX_OBJVRAMMODE_CHAR_1D_32K
		};
		CATS_SystemInit( wk->csp, &coi, &ccmm, 32 );
	}
	CATS_ClactSetInit( wk->csp, wk->crp, WO_CLA_MAX );
	CATS_ResourceManagerInit( wk->csp, wk->crp, &crnl );

	GF_Disp_GX_VisibleControl( GX_PLANEMASK_OBJ, VISIBLE_ON );
	GF_Disp_GXS_VisibleControl( GX_PLANEMASK_OBJ, VISIBLE_ON );
}


//--------------------------------------------------------------------------------------------
/**
 * セルアクター解放
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_ObjFree( WO_WORK * wk )
{
	u32	i;

	for( i=0; i<WO_CLA_MAX; i++ ){
		CATS_ActorPointerDelete_S( wk->cap[i] );
	}
	CATS_ResourceDestructor_S( wk->csp, wk->crp );
	CATS_FreeMemory( wk->csp );
}

//--------------------------------------------------------------------------------------------
/**
 * セルアクターアニメ
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
/*
static void WO_ObjAnm( WO_WORK * wk )
{
	u16	i;

#if 0
	for( i=0; i<WO_CLA_MAX; i++ ){
		CLACT_AnmFrameChg( wk->cap[i]->act, FX32_ONE );
	}
#endif
}
*/

//--------------------------------------------------------------------------------------------
/**
 * 状態異常アイコンのリソース設定
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_ResourceLoad( WO_WORK * wk, ARCHANDLE* p_handle )
{
	u32	i;

	// キャラ
	CATS_LoadResourceCharArcH(
		wk->csp, wk->crp, p_handle,
		NARC_waza_oshie_gra_oam_dw_NCGR, 0, NNS_G2D_VRAM_TYPE_2DSUB, WO_CHR_ID_ARROW_UD );
	CATS_LoadResourceCharArcH(
		wk->csp, wk->crp, p_handle,
		NARC_waza_oshie_gra_list_cur_NCGR, 0, NNS_G2D_VRAM_TYPE_2DSUB, WO_CHR_ID_CURSOR );
	for( i=WO_CHR_ID_TYPE1; i<=WO_CHR_ID_TYPE_MAX; i++ ){
		if(i < WO_CHR_ID_TYPE5){
			WazaTypeIcon_CharResourceLoad( wk->csp, wk->crp, NNS_G2D_VRAM_TYPE_2DSUB, 0, i );
		}else{
			WazaTypeIcon_CharResourceLoad( wk->csp, wk->crp, NNS_G2D_VRAM_TYPE_2DMAIN, 0, i );
		}
	}
	WazaKindIcon_CharResourceLoad(wk->csp,wk->crp,NNS_G2D_VRAM_TYPE_2DSUB,0,WO_CHR_ID_KIND);

	// パレット
	CATS_LoadResourcePlttArcH(
		wk->csp, wk->crp, p_handle,
		NARC_waza_oshie_gra_oam_dw_NCLR, FALSE, DW_ACTPAL_NUM, NNS_G2D_VRAM_TYPE_2DSUB, WO_PAL_ID_OBJ );
	WazaTypeIcon_PlttResourceLoad( wk->csp, wk->crp, NNS_G2D_VRAM_TYPE_2DSUB, WO_PAL_ID_TYPE );
	WazaTypeIcon_PlttResourceLoad( wk->csp, wk->crp, NNS_G2D_VRAM_TYPE_2DMAIN, WO_PAL_ID_TYPE_M );

	// セル
	CATS_LoadResourceCellArcH(
		wk->csp, wk->crp, p_handle,
		NARC_waza_oshie_gra_oam_dw_NCER, 0, WO_CEL_ID_ARROW_UD );
	CATS_LoadResourceCellArcH(
		wk->csp, wk->crp, p_handle,
		NARC_waza_oshie_gra_list_cur_NCER, 0, WO_CEL_ID_CURSOR );

	// セルアニメ
	CATS_LoadResourceCellAnmArcH(
		wk->csp, wk->crp, p_handle,
		NARC_waza_oshie_gra_oam_dw_NANR, 0, WO_ANM_ID_ARROW_UD );
	CATS_LoadResourceCellAnmArcH(
		wk->csp, wk->crp, p_handle,
		NARC_waza_oshie_gra_list_cur_NANR, 0, WO_ANM_ID_CURSOR );

	WazaTypeIcon_CellAnmResourceLoad( wk->csp, wk->crp, WO_CEL_ID_TYPE, WO_ANM_ID_TYPE );
}


//--------------------------------------------------------------------------------------------
/**
 * タイプアイコン切り替え
 *
 * @param	wk		ワーク
 * @param	waza	技番号
 * @param	num		アイコン番号
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_TypeIconChange( WO_WORK * wk, u16 waza, u16 num )
{
	u32	type;

	if( wk->dat->page == WO_PAGE_BATTLE ){
		type = WT_WazaDataParaGet( waza, ID_WTD_wazatype );
	}else{
		type = WT_WazaDataParaGet( waza, ID_WTD_contype ) + ICONTYPE_STYLE;
	}

	CATS_ChangeResourceCharArc(
		wk->csp, wk->crp, WazaTypeIcon_ArcIDGet(),
		WazaTypeIcon_CgrIDGet(type), WAZATYPEICON_COMP_CHAR, WO_CHR_ID_TYPE1+num );

	if(num < LIST_NUM){
		CATS_ObjectPaletteSetCap( wk->cap[WO_CLA_TYPE1+num], WazaTypeIcon_PlttOffsetGet(type)+ TICON_ACTPAL_IDX);
	}else{
		CATS_ObjectPaletteSetCap( wk->cap[WO_CLA_TYPE1+num], WazaTypeIcon_PlttOffsetGet(type)+ TICON_ACTPAL_IDX_M);
	}
}

//--------------------------------------------------------------------------------------------
/**
 * タイプアイコン初期化
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_TypeIconInit( WO_WORK * wk )
{
	u32	i;

	for( i=0; i<LIST_NUM; i++ ){
		CATS_ObjectPosSetCap(
			wk->cap[WO_CLA_TYPE1+i], TYPE_ICON1_PX, TYPE_ICON1_PY+SEL_CURSOR_SY*i );
		if( wk->dat->scr + i >= wk->sel_max ){
			CATS_ObjectEnableCap( wk->cap[WO_CLA_TYPE1+i], 0 );
		}else{
			CATS_ObjectEnableCap( wk->cap[WO_CLA_TYPE1+i], 1 );
			WO_TypeIconChange( wk, wk->dat->waza_tbl[wk->dat->scr+i], i );
		}
	}
}

//--------------------------------------------------------------------------------------------
/**
 * タイプアイコンスクロール
 *
 * @param	wk			ワーク
 * @param	old_scr		今までのスクロールカウンタ
 * @param	new_scr		新しいスクロールカウンタ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_TypeIconScroll( WO_WORK * wk, u16 old_scr, u16 new_scr )
{
	u32	i;
	s16	x, y;

	if( old_scr < new_scr ){
		for( i=0; i<LIST_NUM; i++ ){
			CATS_ObjectPosGetCap( wk->cap[WO_CLA_TYPE1+i], &x, &y );
			if( y == TYPE_ICON1_PY ){
				y = TYPE_ICON4_PY;
				if( wk->dat->waza_tbl[new_scr+LIST_NUM_OFS] != WAZAOSHIE_TBL_MAX ){
					WO_TypeIconChange( wk, wk->dat->waza_tbl[new_scr+LIST_NUM_OFS], i );
				}
			}else{
				y -= SEL_CURSOR_SY;
			}
			CATS_ObjectPosSetCap( wk->cap[WO_CLA_TYPE1+i], x, y );
		}
	}else if( old_scr > new_scr ){
		for( i=0; i<LIST_NUM; i++ ){
			CATS_ObjectPosGetCap( wk->cap[WO_CLA_TYPE1+i], &x, &y );
			if( y == TYPE_ICON4_PY ){
				y = TYPE_ICON1_PY;
				if( wk->dat->waza_tbl[new_scr] != WAZAOSHIE_TBL_MAX ){
					WO_TypeIconChange( wk, wk->dat->waza_tbl[new_scr], i );
				}
			}else{
				y += SEL_CURSOR_SY;
			}
			CATS_ObjectPosSetCap( wk->cap[WO_CLA_TYPE1+i], x, y );
		}
	}else{
		return;
	}

	for( i=0; i<LIST_NUM; i++ ){
		CATS_ObjectPosGetCap( wk->cap[WO_CLA_TYPE1+i], &x, &y );
		y = ( y - TYPE_ICON1_PY ) / SEL_CURSOR_SY;
		if( new_scr + y >= wk->sel_max ){
			CATS_ObjectEnableCap( wk->cap[WO_CLA_TYPE1+i], 0 );
		}else{
			CATS_ObjectEnableCap( wk->cap[WO_CLA_TYPE1+i], 1 );
		}
	}
}


//--------------------------------------------------------------------------------------------
/**
 * 分類アイコン切り替え
 *
 * @param	wk		ワーク
 * @param	waza	技番号
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_KindIconChange( WO_WORK * wk, u16 waza )
{
	u32	kind = WT_WazaDataParaGet( waza, ID_WTD_kind );

	CATS_ChangeResourceCharArc(
		wk->csp, wk->crp, WazaKindIcon_ArcIDGet(),
		WazaKindIcon_CgrIDGet(kind), WAZAKINDICON_COMP_CHAR, WO_CHR_ID_KIND );

	CATS_ObjectPaletteSetCap( wk->cap[WO_CLA_KIND], WazaKindIcon_PlttOffsetGet(kind)+TICON_ACTPAL_IDX );
}


//--------------------------------------------------------------------------------------------
/**
 * セルアクター初期化
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_ObjInit( WO_WORK * wk, ARCHANDLE* p_handle )
{
	u32	i;

	WO_ClactResManInit( wk );
	WO_ResourceLoad( wk, p_handle );

	for( i=0; i<WO_CLA_MAX; i++ ){
		wk->cap[i] = CATS_ObjectAdd_S( wk->csp, wk->crp, &ClactParamTbl[i] );
		CATS_ObjectAutoAnimeSetCap(wk->cap[i],FALSE);
	}
}


/**
 *	@brief	カメラ設定
 */
static void WO_CameraInit(WO_3DWORK* wk,int heapID)		// カメラ
{
	VecFx32	camera_pos = {0,0,0x10000};
	CAMERA_ANGLE angle = {0,0,0};
	fx32	distance   = 0x10000;
	u16		perspway   = 0x05c1;

	wk->camera = GFC_AllocCamera(heapID);

	GFC_InitCameraCDA(&camera_pos,distance,&angle,perspway,GF_CAMERA_ORTHO,wk->camera);
	GFC_SetCameraClip(0,FX32_CONST(100),wk->camera);
	GFC_PurgeCameraTarget(wk->camera);
	GFC_AttachCamera(wk->camera);
}

/**
 *	@brief	ソフトウェアスプライト初期化
 */
static void WO_SoftSpriteInit(WO_3DWORK* wk,POKEMON_PARAM* pp,int heapID)
{
	SOFT_SPRITE_ARC	ssa;

	wk->ssm = SoftSpriteInit(heapID);

	PokeGraArcDataGetPP( &ssa,pp,PARA_FRONT);

	wk->ss = SoftSpriteAdd( wk->ssm, &ssa,POKE_PX,POKE_PY, 0, 0, NULL, NULL );
	SoftSpriteParaSet( wk->ss, SS_PARA_H_FLIP,
		PokeFormNoPersonalParaGet(PokeParaGet(pp,ID_PARA_monsno,NULL),PokeParaGet(pp,ID_PARA_form_no,NULL),ID_PER_reverse )^1 );
//		PokePersonalParaGet(PokeParaGet(pp,ID_PARA_monsno,NULL), ID_PER_reverse ) ^ 1);
}

//--------------------------------------------------------------------------------------------
/**
 * 3D/ソフトウェアスプライト初期化
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_3DInit( WO_WORK * wk )
{
	NNS_G3dInit();		// NitroSystem:３Ｄエンジンの初期化
	G3X_Init();
	G3X_InitMtxStack();
	G3X_SetShading( GX_SHADING_TOON );
	G3X_AlphaTest( FALSE, 0 );
	G3X_AlphaBlend( TRUE );
	G3X_AntiAlias( TRUE );
	G3X_EdgeMarking( FALSE );
	G3X_SetFog( FALSE, 0, 0, 0 );
	G3X_SetClearColor( 0, 0, 0x7fff, 63, FALSE );
	G3_SwapBuffers( GX_SORTMODE_AUTO, GX_BUFFERMODE_W );
	G3_ViewPort( 0, 0, 255, 191 );

	MI_CpuClear8(&wk->p3d,sizeof(WO_3DWORK));

	//カメラ初期化
	WO_CameraInit(&wk->p3d,HEAPID_WAZAOSHIE);

	//ソフトウェアスプライト初期化
	WO_SoftSpriteInit(&wk->p3d,wk->dat->pp,HEAPID_WAZAOSHIE);

	GF_Disp_GX_VisibleControl( GX_PLANEMASK_BG0, VISIBLE_ON );
    G2_SetBG0Priority(MFRM_POKE_PRI);
}

/**
 *	@brief	ソフトウェアスプライト　3Dメイン
 */
static void WO_3DMain(WO_3DWORK* wk)
{
	GF_G3X_Reset();
	GFC_CameraLookAt();

	G3_MtxMode( GX_MTXMODE_PROJECTION );
	G3_Identity();
	G3_MtxMode( GX_MTXMODE_POSITION_VECTOR );
	G3_Identity();

	NNS_G3dGlbFlush();
	NNS_G2dSetupSoftwareSpriteCamera();
	SoftSpriteMain( wk->ssm );

	G3_SwapBuffers( GX_SORTMODE_MANUAL, GX_BUFFERMODE_Z );
}


//--------------------------------------------------------------------------------------------
/**
 * 3D/ソフトウェアスプライト解放
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_3DRelease( WO_3DWORK * wk )
{
	GFC_FreeCamera(wk->camera);
	SoftSpriteEnd(wk->ssm);
	MI_CpuClear8(wk,sizeof(WO_3DWORK));
}

//--------------------------------------------------------------------------------------------
/**
 * 技選択カーソル切り替え
 *
 * @param	wk		ワーク
 * @param	pos		表示位置
 * @param	pal		表示パレット
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_SelCursorChange( WO_WORK * wk, u8 pos, u8 pal )
{
	if(pos < LIST_NUM){
		CATS_ObjectPosSetCap(wk->cap[WO_CLA_CURSOR],
			SEL_CURSOR_PX, SEL_CURSOR_PY+SEL_CURSOR_SY*pos );
		CATS_ObjectAnimeFrameSetCap(wk->cap[WO_CLA_CURSOR],0);
	}else if(pos < (LIST_NUM+2)){
		CATS_ObjectPosSetCap(wk->cap[WO_CLA_CURSOR],
			SEL_CURSOR_P_PX+(pos-LIST_NUM)*SEL_CURSOR_P_SX, SEL_CURSOR_P_PY);
		CATS_ObjectAnimeFrameSetCap(wk->cap[WO_CLA_CURSOR],1);
	}else{
		CATS_ObjectPosSetCap(wk->cap[WO_CLA_CURSOR],
			SEL_CURSOR_B_PX, SEL_CURSOR_B_PY);
		CATS_ObjectAnimeFrameSetCap(wk->cap[WO_CLA_CURSOR],2);
	}
	CATS_ObjectPaletteSetCap( wk->cap[WO_CLA_CURSOR], pal );
}



//--------------------------------------------------------------------------------------------
/**
 * スクロールカーソル表示切替
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WO_ScrollCursorPut( WO_WORK * wk ,u8 idx,BOOL anm_f)
{
	u8 flag;

	if(idx == 0 && anm_f){
		flag = 1;
		CATS_ObjectAnimeReStartCap(wk->cap[WO_CLA_ARROW_D]);
	}else{
		flag = 0;
	}
	if( wk->dat->scr + LIST_NUM < wk->sel_max ){
		CATS_ObjectAnimeSeqSetCap( wk->cap[WO_CLA_ARROW_D],ANMDW_ARROW_DT+flag);
	}else{
		CATS_ObjectAnimeSeqSetCap( wk->cap[WO_CLA_ARROW_D],ANMDW_ARROW_DF+flag);
	}
	CATS_ObjectAutoAnimeSetCap(wk->cap[WO_CLA_ARROW_D],flag);

	if(idx == 1 && anm_f){
		flag = 1;
		CATS_ObjectAnimeReStartCap(wk->cap[WO_CLA_ARROW_U]);
	}else{
		flag = 0;
	}
	if( wk->dat->scr != 0 ){
		CATS_ObjectAnimeSeqSetCap( wk->cap[WO_CLA_ARROW_U],ANMDW_ARROW_UT+flag);
	}else{
		CATS_ObjectAnimeSeqSetCap( wk->cap[WO_CLA_ARROW_U],ANMDW_ARROW_UF+flag);
	}
	CATS_ObjectAutoAnimeSetCap(wk->cap[WO_CLA_ARROW_U],flag);
}

//--------------------------------------------------------------------------------------------
/**
 * スクロールカーソル非表示
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
/*
static void WO_ScrollCursorOff( WO_WORK * wk )
{
	CATS_ObjectEnableCap( wk->cap[WO_CLA_ARROW_U], 0 );
	CATS_ObjectEnableCap( wk->cap[WO_CLA_ARROW_D], 0 );
}
*/


//--------------------------------------------------------------------------------------------
/**
 * ステータス画面呼び出しセット
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqPstInit( WO_WORK * wk )
{
	APP_WipeStart( APP_WIPE_OUT, HEAPID_WAZAOSHIE );
	wk->next_seq = SEQ_PST_CALL;
	return SEQ_FADE_WAIT;
}

//--------------------------------------------------------------------------------------------
/**
 * ステータス画面呼び出し
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqPstCall( WO_WORK * wk )
{
	u8 page[] = {
		PST_PAGE_PARAM_B_SKILL,		// 「たたかうわざ」
		PST_PAGE_MAX
	};

	WO_DispExit( wk );

	wk->psd.ppd  = wk->dat->pp;
	wk->psd.cfg  = wk->dat->cfg;
	wk->psd.ppt  = PST_PP_TYPE_POKEPARAM;
	wk->psd.pos  = 0;
	wk->psd.max  = 1;
	wk->psd.waza = WO_SelWazaGet( wk );
	wk->psd.mode = PST_MODE_WAZAADD;
	wk->psd.ev_contest = 1;
	wk->psd.perap = NULL;
	wk->psd.kt_status = NULL;


	PokeStatus_PageSet( &wk->psd, page );

	wk->subProc = PROC_Create( &PokeStatusProcData, &wk->psd, HEAPID_WAZAOSHIE );
	return SEQ_PST_WAIT;
}

//--------------------------------------------------------------------------------------------
/**
 * ステータス画面終了待ち
 *
 * @param	wk		ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int WO_SeqPstWait( WO_WORK * wk )
{
	if( ProcMain( wk->subProc ) ){
        PROC_Delete( wk->subProc );
		WO_DispInit( wk );
		WazaSelBgChange( wk, wk->dat->pos );
		WO_SelCursorChange( wk, wk->dat->pos, PALDW_CURSOR);
//		WO_ScrollCursorOff( wk );
		wk->dat->del_pos = wk->psd.ret_sel;
		wk->next_seq = SEQ_DEL_CHECK;
		return SEQ_FADE_WAIT;
	}

	return SEQ_PST_WAIT;
}






//============================================================================================
//============================================================================================
//============================================================================================
//============================================================================================
//============================================================================================
//============================================================================================
static void CursorMoveCallBack( void * work, int now_pos, int old_pos );
static void CursorMoveCallBack_Move( void * work, int now_pos, int old_pos );
static void CursorMoveCallBack_Touch( void * work, int now_pos, int old_pos );

static void ScrollButtonOnOff( WO_WORK * wk );
static void EnterButtonOnOff( WO_WORK * wk, BOOL flg );

static void ScrollButtonAnmChange( WO_WORK * wk, s32 mv );


static const RECT_HIT_TBL ListHitTbl[] =
{
	{TP_WAZA1_PY,TP_WAZA1_PY+TP_WAZA_SY-1,TP_WAZA_PX,TP_WAZA_PX+TP_WAZA_SX-1},
	{TP_WAZA2_PY,TP_WAZA2_PY+TP_WAZA_SY-1,TP_WAZA_PX,TP_WAZA_PX+TP_WAZA_SX-1},
	{TP_WAZA3_PY,TP_WAZA3_PY+TP_WAZA_SY-1,TP_WAZA_PX,TP_WAZA_PX+TP_WAZA_SX-1},
	{TP_WAZA4_PY,TP_WAZA4_PY+TP_WAZA_SY-1,TP_WAZA_PX,TP_WAZA_PX+TP_WAZA_SX-1},
	{TP_SB_PY,TP_SB_PY+TP_SB_SY-1,TP_SBD_PX,TP_SBD_PX+TP_SB_SX-1},
	{TP_SB_PY,TP_SB_PY+TP_SB_SY-1,TP_SBU_PX,TP_SBU_PX+TP_SB_SX-1},
	{TP_BACK_PY,TP_BACK_PY+TP_BACK_SY-1,TP_BACK_PX,TP_BACK_PX+TP_BACK_SX-1},
	{TP_ABTN_PY,TP_ABTN_PY+TP_ABTN_SY-1,TP_ABTN_PX,TP_ABTN_PX+TP_ABTN_SX-1},
	{RECT_HIT_END,0,0,0}
};
static const POINTER_WORK ListKeyTbl[] =
{
	{ 40,  52, 0, 0,	6, 1, 0, 0 },	// 00: 技１（ダミーで「もどる」にループ）
	{ 80,  60, 0, 0,	0, 2, 1, 1 },	// 01: 技２
	{ 40,  84, 0, 0,	1, 3, 2, 2 },	// 02: 技３
	{ 80,  92, 0, 0,	2, 6, 3, 3 },	// 03: 技４

	{ 40, 116, 0, 0,	4, 4, 4, 4 },	// 04: 下矢印
	{ 80, 124, 0, 0,	5, 5, 5, 5 },	// 05: 上矢印

	{ 224, 168, 0, 0,	3, 6, 6, 6 },	// 06: もどる
	{ 224, 168, 0, 0,	7, 7, 7, 7 },	// 07: おぼえる
};
static const CURSORMOVE_CALLBACK ListCallBack = {
	CursorMoveCallBack,
	CursorMoveCallBack,
	CursorMoveCallBack_Move,
	CursorMoveCallBack_Touch
};

static void CursorMoveInit( WO_WORK * wk )
{
	wk->cmwk = CURSORMOVE_Create(
					ListHitTbl, ListKeyTbl, &ListCallBack, wk, TRUE, 0, HEAPID_WAZAOSHIE );

	EnterButtonOnOff( wk, FALSE );	// 決定を消す
	ScrollButtonOnOff( wk );		// スクロール設定
}

static void CursorMoveExit( WO_WORK * wk )
{
	CURSORMOVE_Exit( wk->cmwk );
}

/*
static void CM_CursorPut( WO_WORK * wk, int pos )
{
}
*/

static void CursorMoveCallBack( void * work, int now_pos, int old_pos )
{
	// ダミー関数
}

static void CursorMoveCallBack_Move( void * work, int now_pos, int old_pos )
{
	WO_WORK * wk = work;

	// 決定を消す
	EnterButtonOnOff( wk, FALSE );
	WazaSelBgChange( wk, 5 );

	// 技
	if( now_pos <= 3 ){
		Snd_SePlay( WO_SE_LIST_MOVE );
		wk->dat->pos = now_pos;
		if( wk->dat->scr + wk->dat->pos < wk->sel_max ){
			BattleWazaParamPut( wk, WO_SelWazaGet( wk ) );
		}else{
			BattleWazaParamPut( wk, BMPLIST_CANCEL );
		}
	//「もどる」
	}else if( now_pos == 6 ){
		// 下の技から
		if( old_pos == 3 && wk->dat->scr + 4 < wk->sel_max ){
//			Snd_SePlay( WO_SE_LIST_MOVE );
			Snd_SePlay( WO_SE_PAGE_MOVE );
			now_pos = 3;
			CURSORMOVE_PosSet( wk->cmwk, now_pos );
			wk->dat->scr++;
			WO_WazaListDraw( wk );
			BattleWazaParamPut( wk, WO_SelWazaGet( wk ) );
			ScrollButtonOnOff( wk );
			ScrollButtonAnmChange( wk, 1 );
		// 上の技から
		}else if( old_pos == 0 ){
			if( wk->dat->scr != 0 ){
//				Snd_SePlay( WO_SE_LIST_MOVE );
				Snd_SePlay( WO_SE_PAGE_MOVE );
				wk->dat->scr--;
				WO_WazaListDraw( wk );
				BattleWazaParamPut( wk, WO_SelWazaGet( wk ) );
				ScrollButtonOnOff( wk );
				ScrollButtonAnmChange( wk, -1 );
			}
			now_pos = 0;
			CURSORMOVE_PosSet( wk->cmwk, now_pos );
		}else{
			Snd_SePlay( WO_SE_LIST_MOVE );
			BattleWazaParamPut( wk, BMPLIST_CANCEL );
		}
	// その他
	}else{
		Snd_SePlay( WO_SE_LIST_MOVE );
	}

	WO_SelCursorChange( wk, now_pos, PALDW_CURSOR );
}

static void CursorMoveCallBack_Touch( void * work, int now_pos, int old_pos )
{
	WO_WORK * wk = work;

	// 技
	if( now_pos <= 3 ){
		wk->dat->pos = now_pos;
		if( wk->dat->scr + wk->dat->pos < wk->sel_max ){
			WazaSelBgChange( wk, wk->dat->scr );
			EnterButtonOnOff( wk, TRUE );	// 決定を表示
			BattleWazaParamPut( wk, WO_SelWazaGet( wk ) );
		}else{
			WazaSelBgChange( wk, 5 );
			EnterButtonOnOff( wk, FALSE );	// 決定を消す
			BattleWazaParamPut( wk, BMPLIST_CANCEL );
		}
	// 下
	}else if( now_pos == 4 ){
		Snd_SePlay( WO_SE_PAGE_MOVE );
		now_pos = wk->dat->pos;
		wk->dat->scr++;
		BattleWazaParamPut( wk, WO_SelWazaGet( wk ) );
		WO_WazaListDraw( wk );
		WazaSelBgChange( wk, 5 );
		EnterButtonOnOff( wk, FALSE );	// 決定を消す
		ScrollButtonOnOff( wk );
		ScrollButtonAnmChange( wk, 1 );
		CURSORMOVE_PosSet( wk->cmwk, now_pos );
	// 上
	}else if( now_pos == 5 ){
		Snd_SePlay( WO_SE_PAGE_MOVE );
		now_pos = wk->dat->pos;
		wk->dat->scr--;
		BattleWazaParamPut( wk, WO_SelWazaGet( wk ) );
		WO_WazaListDraw( wk );
		WazaSelBgChange( wk, 5 );
		EnterButtonOnOff( wk, FALSE );	// 決定を消す
		ScrollButtonOnOff( wk );
		ScrollButtonAnmChange( wk, -1 );
		CURSORMOVE_PosSet( wk->cmwk, now_pos );
	// もどる
	}else if( now_pos == 6 ){
		WazaSelBgChange( wk, 5 );
		EnterButtonOnOff( wk, FALSE );	// 決定を消す
		if( wk->cm_pos != 6 ){
			now_pos = wk->dat->pos;
			CURSORMOVE_PosSet( wk->cmwk, now_pos );
		}
	// けってい
	}else if( now_pos == 7 ){
		now_pos = wk->dat->pos;
		CURSORMOVE_PosSet( wk->cmwk, now_pos );
	}

	WO_SelCursorChange( wk, now_pos, PALDW_CURSOR );
}

static void EnterButtonOnOff( WO_WORK * wk, BOOL flg )
{
	// 表示
	if( flg == TRUE ){
		CURSORMOVE_MoveTableBitOn( wk->cmwk, 7 );
		GF_BGL_BmpWinOnVReq( &wk->win[WIN_ABTN] );
		WO_SubBGPartsDraw(
			wk, BG_ABTN_PX, BG_ABTN_PY, BG_ABTN_SX, BG_ABTN_SY, BG_ABTN_OX+BG_ABTN_SX, BG_ABTN_OY );
		wk->enter_flg = 1;
	// 非表示
	}else{
		CURSORMOVE_MoveTableBitOff( wk->cmwk, 7 );
		GF_BGL_BmpWinOffVReq( &wk->win[WIN_ABTN] );
		WO_SubBGPartsDraw(
			wk, BG_ABTN_PX, BG_ABTN_PY, BG_ABTN_SX, BG_ABTN_SY, BG_ABTN_OX, BG_ABTN_OY );
		wk->enter_flg = 0;
	}
}

static void ScrollButtonOnOff( WO_WORK * wk )
{
	if( wk->sel_max < 4 ){
		CURSORMOVE_MoveTableBitOff( wk->cmwk, 4 );
		CURSORMOVE_MoveTableBitOff( wk->cmwk, 5 );
		return;
	}

	if( wk->dat->scr == 0 ){
		CURSORMOVE_MoveTableBitOff( wk->cmwk, 5 );
	}else{
		CURSORMOVE_MoveTableBitOn( wk->cmwk, 5 );
	}

	if( wk->dat->scr + 4 >= wk->sel_max ){
		CURSORMOVE_MoveTableBitOff( wk->cmwk, 4 );
	}else{
		CURSORMOVE_MoveTableBitOn( wk->cmwk, 4 );
	}
}

static void ScrollButtonAnmChange( WO_WORK * wk, s32 mv )
{
	CATS_ObjectAutoAnimeSetCap( wk->cap[WO_CLA_ARROW_U], TRUE );
	CATS_ObjectAutoAnimeSetCap( wk->cap[WO_CLA_ARROW_D], TRUE );
	CATS_ObjectAnimeFrameSetCap( wk->cap[WO_CLA_ARROW_U], 0 );
	CATS_ObjectAnimeFrameSetCap( wk->cap[WO_CLA_ARROW_D], 0 );

	if( mv > 0 ){
		if( wk->dat->scr + 4 < wk->sel_max ){
			CATS_ObjectAnimeSeqSetCap( wk->cap[WO_CLA_ARROW_D], ANMDW_ARROW_DTA);
		}else{
			CATS_ObjectAnimeSeqSetCap( wk->cap[WO_CLA_ARROW_D], ANMDW_ARROW_DFA );
		}
		CATS_ObjectAnimeSeqSetCap( wk->cap[WO_CLA_ARROW_U], ANMDW_ARROW_UT );
	}else{
		if( wk->dat->scr == 0 ){
			CATS_ObjectAnimeSeqSetCap( wk->cap[WO_CLA_ARROW_U], ANMDW_ARROW_UFA);
		}else{
			CATS_ObjectAnimeSeqSetCap( wk->cap[WO_CLA_ARROW_U], ANMDW_ARROW_UTA );
		}
		CATS_ObjectAnimeSeqSetCap( wk->cap[WO_CLA_ARROW_D], ANMDW_ARROW_DT );
	}
}

static void WazaSelBgChange( WO_WORK * wk, u32 pos )
{
	u32	i;

	for( i=0; i<4; i++ ){
		if( i == pos ){
			WO_SubBGPartsDraw(
				wk, BG_WLIST_PX, WIN_LIST_PY+(i*BG_WLIST_SY),
				BG_WLIST_SX, BG_WLIST_SY, BG_WLIST_SPX, BG_WLIST_SPY+BG_WLIST_SY*2 );
		}else{
			if( i >= wk->sel_max ){
				WO_SubBGPartsDraw(
					wk, BG_WLIST_PX, WIN_LIST_PY+(i*BG_WLIST_SY),
					BG_WLIST_SX, BG_WLIST_SY, BG_WLIST_SPX, BG_WLIST_SPY+BG_WLIST_SY );
			}else{
				WO_SubBGPartsDraw(
					wk, BG_WLIST_PX, WIN_LIST_PY+(i*BG_WLIST_SY),
					BG_WLIST_SX, BG_WLIST_SY, BG_WLIST_SPX, BG_WLIST_SPY );
			}
		}
	}
}


static int RetButtonAnmInit( WO_WORK * wk, int next )
{
	BUTTON_ANM_WORK * bawk = &wk->button_anm_work;

	bawk->px = 24;
	bawk->py = 20;
	bawk->sx = 8;
	bawk->sy = 4;

	bawk->cnt = 0;
	bawk->seq = 0;

	bawk->next = next;

	return SEQ_BUTTON_ANM;
}

static int EnterButtonAnmInit( WO_WORK * wk, int next )
{
	BUTTON_ANM_WORK * bawk = &wk->button_anm_work;

	bawk->px = 16;
	bawk->py = 20;
	bawk->sx = 8;
	bawk->sy = 4;

	bawk->cnt = 0;
	bawk->seq = 0;

	bawk->next = next;

	return SEQ_BUTTON_ANM;
}

static int ButtonAnmMaun( WO_WORK * wk )
{
	BUTTON_ANM_WORK * bawk = &wk->button_anm_work;

	switch( bawk->seq ){
	case 0:
		GF_BGL_ScrPalChange( wk->bgl, SFRM_BACK, bawk->px, bawk->py, bawk->sx, bawk->sy, 7 );
		GF_BGL_LoadScreenV_Req( wk->bgl, SFRM_BACK );
		bawk->seq++;
		break;

	case 1:
		bawk->cnt++;
		if( bawk->cnt == 4 ){
			GF_BGL_ScrPalChange( wk->bgl, SFRM_BACK, bawk->px, bawk->py, bawk->sx, bawk->sy, 0 );
			GF_BGL_LoadScreenV_Req( wk->bgl, SFRM_BACK );
			bawk->cnt = 0;
			bawk->seq++;
		}
		break;

	case 2:
		bawk->cnt++;
		if( bawk->cnt == 2 ){
			return bawk->next;
		}
	}

	return SEQ_BUTTON_ANM;
}


static int WO_SeqRetButton( WO_WORK * wk )
{
//	WO_SelCursorChange( wk, wk->dat->pos, PALDW_CURSOR);
//	WO_ScrollCursorOff( wk );
	WO_TalkMsgSet( wk, MSG_END_CHECK );
	wk->ynidx = YESNO_END_CHECK;
	wk->next_seq = SEQ_YESNO_PUT;
	return SEQ_MSG_WAIT;
}

static int WO_SeqEnterButton( WO_WORK * wk )
{
	return WazaSelectEnter( wk );
}

static int WazaSelectEnter( WO_WORK * wk )
{
	if( WO_WazaSetCheck( wk ) < 4 ){
		WO_TalkMsgSet( wk, MSG_SET_CHECK );
		wk->ynidx = YESNO_SET_CHECK;
		wk->next_seq = SEQ_YESNO_PUT;
	}else{
		WO_TalkMsgSet( wk, MSG_CHG_CHECK );
		wk->ynidx = YESNO_CHG_CHECK;
		wk->next_seq = SEQ_YESNO_PUT;
	}
	return SEQ_MSG_WAIT;
}

static void PassiveSet( BOOL flg )
{
	if( flg == TRUE ){
		G2S_SetBlendBrightness(
			GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 |
			GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ, -8 );
	}else{
		G2S_BlendNone();
	}
}